من میخوام ویژگی چند مقداری را به پرستا اضافه کنم و ویژگی را وابسته به شاخه کنم و همچنین مقادیر feature_value را ارزش گزاری کنم. واسه اینکار دو فیلد id_category و multi_value به جدول و کلاس feature اضافه کردم و فیلد number_value را به کلاس و جدول feature_value و این مقادیر و کنترل های مربوطه را به adminFeatureController اضافه کردم و در پوشه override و سر جایشان قرار دادم. حالا فیلدی که با نام number_value به feature_value اضافه کردم کار میکنه ولی وقتی میخوام یه ویژگی اضافه کنم با اینکه کنترلر های مربوط به دو مقدار id_category و multi_value به صفحه مربط به افزودن ویژگی جدید اضافه شدن و مینویسه ویژگی با موفقیت اضافه شد ولی این دو فیلد جدید انگار که اصلا وجود ندارن و مقادیری که انتخاب کردم به جدول feature اضافه نمیشه. feature
class Feature extends FeatureCore
{
public $id_category;
public $multi_value;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'feature',
'primary' => 'id_feature',
'multilang' => true,
'fields' => array(
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
// Category ID
'id_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'multi_value' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
)
);
}
feature_value
class FeatureValue extends FeatureValueCore
{
public $number_value;
public static $definition = array(
'table' => 'feature_value',
'primary' => 'id_feature_value',
'multilang' => true,
'fields' => array(
'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'number_value' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'value' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
),
);
public static function getFeatureValuesWithLang($id_lang, $id_feature, $custom = false)
{
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'feature_value` v
LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl
ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.')
WHERE v.`id_feature` = '.(int)$id_feature.'
'.(!$custom ? 'AND (v.`custom` IS NULL OR v.`custom` = 0)' : '').'
ORDER BY v.`numbar_value` ASC', true, false
);
}
}
َAdminFeatureController
class AdminFeaturesController extends AdminFeaturesControllerCore
{
public function __construct()
{
$this->table = 'feature';
$this->className = 'Feature';
$this->list_id = 'feature';
$this->identifier = 'id_feature';
$this->lang = true;
$this->fields_list = array(
'id_feature' => array(
'title' => $this->l('ID'),
'align' => 'center',
'class' => 'fixed-width-xs'
),
'name' => array(
'title' => $this->l('Name'),
'width' => 'auto',
'filter_key' => 'b!name'
),
'value' => array(
'title' => $this->l('Values'),
'orderby' => false,
'search' => false,
'align' => 'center',
'class' => 'fixed-width-xs'
),
'id_category' => array(
'title' => $this->l('Category ID'),
'align' => 'center',
'class' => 'fixed-width-xs'
),
'multi_value' => array(
'title' => $this->l('Multiple Value'),
'align' => 'center',
'class' => 'fixed-width-xs'
),
'position' => array(
'title' => $this->l('Position'),
'filter_key' => 'a!position',
'align' => 'center',
'class' => 'fixed-width-xs',
'position' => 'position'
)
);
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'icon' => 'icon-trash',
'confirm' => $this->l('Delete selected items?')
)
);
AdminController::__construct();
}
/**
* AdminController::renderForm() override
* @see AdminController::renderForm()
*/
public function renderForm()
{
$this->toolbar_title = $this->l('Add a new feature');
$selected_categories = array((int)Tools::getValue('id_parent', Category::getRootCategory()->id));
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Feature'),
'icon' => 'icon-info-sign'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'lang' => true,
'size' => 33,
'hint' => $this->l('Invalid characters:').' <>;=#{}',
'required' => true
),
array(
'type' => 'categories',
'label' => $this->l('Associate category'),
'name' => 'id_category',
'tree' => array(
'id' => 'categories-tree',
'selected_categories' => $selected_categories,
'disabled_categories' => null,
'required' => true
)
),
array(
'type' => 'switch',
'label' => $this->l('Multiple Value'),
'name' => 'multi_value',
'required' => true,
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
)
)
)
);
if (Shop::isFeatureActive())
{
$this->fields_form['input'][] = array(
'type' => 'shop',
'label' => $this->l('Shop association'),
'name' => 'checkBoxShopAsso',
);
}
$this->fields_form['submit'] = array(
'title' => $this->l('Save'),
);
return AdminController::renderForm();
}
/**
* AdminController::renderForm() override
* @see AdminController::renderForm()
*/
public function initFormFeatureValue()
{
$this->setTypeValue();
$this->fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->l('Feature value'),
'icon' => 'icon-info-sign'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Feature'),
'name' => 'id_feature',
'options' => array(
'query' => Feature::getFeatures($this->context->language->id),
'id' => 'id_feature',
'name' => 'name'
),
'required' => true
),
array(
'type' => 'text',
'label' => $this->l('Value'),
'name' => 'value',
'lang' => true,
'size' => 33,
'hint' => $this->l('Invalid characters:').' <>;=#{}',
'required' => true
),
array(
'type' => 'text',
'label' => $this->l('Number Value'),
'name' => 'number_value',
'size' => 33,
'hint' => $this->l('Numeric Field'),
'required' => false
),
),
'submit' => array(
'title' => $this->l('Save'),
),
'buttons' => array(
'save-and-stay' => array(
'title' => $this->l('Save then add another value'),
'name' => 'submitAdd'.$this->table.'AndStay',
'type' => 'submit',
'class' => 'btn btn-default pull-right',
'icon' => 'process-icon-save'
)
)
);
$this->fields_value['id_feature'] = (int)Tools::getValue('id_feature');
// Create Object FeatureValue
$feature_value = new FeatureValue(Tools::getValue('id_feature_value'));
$this->tpl_vars = array(
'feature_value' => $feature_value,
);
$this->getlanguages();
$helper = new HelperForm();
$helper->show_cancel_button = true;
$back = Tools::safeOutput(Tools::getValue('back', ''));
if (empty($back))
$back = self::$currentIndex.'&token='.$this->token;
if (!Validate::isCleanHtml($back))
die(Tools::displayError());
$helper->back_url = $back;
$helper->currentIndex = self::$currentIndex;
$helper->token = $this->token;
$helper->table = $this->table;
$helper->identifier = $this->identifier;
$helper->override_folder = 'feature_value/';
$helper->id = $feature_value->id;
$helper->toolbar_scroll = false;
$helper->tpl_vars = $this->tpl_vars;
$helper->languages = $this->_languages;
$helper->default_form_language = $this->default_form_language;
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
$helper->fields_value = $this->getFieldsValue($feature_value);
$helper->toolbar_btn = $this->toolbar_btn;
$helper->title = $this->l('Add a new feature value');
$this->content .= $helper->generateForm($this->fields_form);
}
}
ممنون میشم کمکم کنید