199 lines
5.4 KiB
PHP
199 lines
5.4 KiB
PHP
<?php
|
|
/**
|
|
* 2022 ECSoft
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to dev.ecsoft@gmail.com so we can send you a copy immediately.
|
|
*
|
|
* @author ECSoft <dev.ecsoft@gmail.com>
|
|
* @copyright 2022 ECSoft
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
* International Registered Trademark & Property of ECSoft
|
|
*/
|
|
include_once dirname(__FILE__) . '/EcsGtmProModelAbstract.php';
|
|
|
|
class EcsGtmProGtmDataConfig extends EcsGtmProModelAbstract
|
|
{
|
|
public $display_variant_id;
|
|
public $display_categories;
|
|
public $product_id;
|
|
public $product_name;
|
|
public $category_name;
|
|
public $lang;
|
|
public $wholesale_price;
|
|
|
|
|
|
public function productIdSelectOptions()
|
|
{
|
|
return array(
|
|
array(
|
|
'id' => 'id',
|
|
'name' => $this->l('ID')
|
|
),
|
|
array(
|
|
'id' => 'reference',
|
|
'name' => $this->l('Reference')
|
|
),
|
|
array(
|
|
'id' => 'ean13',
|
|
'name' => $this->l('EAN13')
|
|
),
|
|
array(
|
|
'id' => 'upc',
|
|
'name' => $this->l('UPC')
|
|
)
|
|
);
|
|
}
|
|
|
|
public function langSelectOptions()
|
|
{
|
|
$array = array(
|
|
array(
|
|
'id' => 'default',
|
|
'name' => $this->l('Default')
|
|
)
|
|
);
|
|
|
|
$langs = Context::getContext()->controller->getLanguages();
|
|
foreach ($langs as $lang) {
|
|
$array[] = array(
|
|
'id' => $lang['id_lang'],
|
|
'name' => $lang['name']
|
|
);
|
|
}
|
|
return $array;
|
|
}
|
|
|
|
public function categoryNameSelectOptions()
|
|
{
|
|
return array(
|
|
array(
|
|
'id' => 'name',
|
|
'name' => $this->l('Name')
|
|
),
|
|
array(
|
|
'id' => 'link_rewrite',
|
|
'name' => $this->l('Link Rewrite')
|
|
),
|
|
array(
|
|
'id' => 'id',
|
|
'name' => $this->l('ID')
|
|
)
|
|
);
|
|
}
|
|
|
|
public function productNameSelectOptions()
|
|
{
|
|
return array(
|
|
array(
|
|
'id' => 'name',
|
|
'name' => $this->l('Name')
|
|
),
|
|
array(
|
|
'id' => 'link_rewrite',
|
|
'name' => $this->l('Link Rewrite')
|
|
),
|
|
array(
|
|
'id' => 'id',
|
|
'name' => $this->l('ID')
|
|
)
|
|
);
|
|
}
|
|
|
|
public function displayVariantIdSelectOptions()
|
|
{
|
|
return array(
|
|
array(
|
|
'id' => 'ifset',
|
|
'name' => $this->l('Only if set')
|
|
),
|
|
array(
|
|
'id' => 'always',
|
|
'name' => $this->l('Always')
|
|
),
|
|
array(
|
|
'id' => 'never',
|
|
'name' => $this->l('Never')
|
|
)
|
|
);
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return array(
|
|
array(
|
|
array(
|
|
'display_variant_id',
|
|
'display_categories',
|
|
'product_id',
|
|
'product_name',
|
|
'category_name',
|
|
'lang',
|
|
'wholesale_price'
|
|
), 'safe'
|
|
)
|
|
);
|
|
}
|
|
|
|
public function attributeDefaults()
|
|
{
|
|
return array(
|
|
'display_variant_id' => 'ifset',
|
|
'display_categories' => 0,
|
|
'product_id' => 'id',
|
|
'product_name' => 'name',
|
|
'category_name' => 'name',
|
|
'lang' => 'default',
|
|
'wholesale_price' => 0
|
|
);
|
|
}
|
|
|
|
public function attributeLabels()
|
|
{
|
|
return array(
|
|
'display_variant_id' => $this->l('Add id of the product variant', 'EcsGtmProGtmDataConfig'),
|
|
'display_categories' => $this->l('Add category hierarchy', 'EcsGtmProGtmDataConfig'),
|
|
'product_id' => $this->l('Product ID field', 'EcsGtmProGtmDataConfig'),
|
|
'product_name' => $this->l('Product name field', 'EcsGtmProGtmDataConfig'),
|
|
'category_name' => $this->l('Category name field', 'EcsGtmProGtmDataConfig'),
|
|
'lang' => $this->l('Language for DataLayer', 'EcsGtmProGtmDataConfig'),
|
|
'wholesale_price' => $this->l('Add wholesale price to DataLayer', 'EcsGtmProGtmDataConfig'),
|
|
);
|
|
}
|
|
|
|
public function attributeDescriptions()
|
|
{
|
|
return array(
|
|
'display_categories' => $this->l('Display category with all parents categories: "/cat1/cat2/cat3" instead of "cat3"', 'EcsGtmProGtmDataConfig'),
|
|
);
|
|
}
|
|
|
|
public function attributeTypes()
|
|
{
|
|
return array(
|
|
'display_variant_id' => 'select',
|
|
'product_id' => 'select',
|
|
'product_name' => 'select',
|
|
'category_name' => 'select',
|
|
'lang' => 'select'
|
|
);
|
|
}
|
|
|
|
public function configKey()
|
|
{
|
|
return 'ecsgtm_data';
|
|
}
|
|
|
|
public function getActiveTab()
|
|
{
|
|
return 'EcsGtmProGtmConfig';
|
|
}
|
|
}
|