From 8a6d40ef175243b5484b6d4e3d5564f299432af7 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Mon, 3 Sep 2012 13:58:18 +0000 Subject: [PATCH] [-] BO: Fix PSCFV-3865 --- controllers/admin/AdminProductsController.php | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index dc3a3ef15..099eddd7a 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3893,52 +3893,50 @@ class AdminProductsControllerCore extends AdminController public function initFormFeatures($obj) { - if (!Feature::isFeatureActive()) - { - $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' '.$this->l('Performances').''); - return; - } - $data = $this->createTemplate($this->tpl_form); - if ($obj->id) + if (!Feature::isFeatureActive()) + $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' '.$this->l('Performances').''); + else { - if ($this->product_exists_in_shop) + if ($obj->id) { - $features = Feature::getFeatures($this->context->language->id); - - foreach ($features as $k => $tab_features) + if ($this->product_exists_in_shop) { - $features[$k]['current_item'] = false; - $features[$k]['val'] = array(); + $features = Feature::getFeatures($this->context->language->id); - $custom = true; - foreach ($obj->getFeatures() as $tab_products) - if ($tab_products['id_feature'] == $tab_features['id_feature']) - $features[$k]['current_item'] = $tab_products['id_feature_value']; + foreach ($features as $k => $tab_features) + { + $features[$k]['current_item'] = false; + $features[$k]['val'] = array(); - $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int)$tab_features['id_feature']); - if (count($features[$k]['featureValues'])) - foreach ($features[$k]['featureValues'] as $value) - if ($features[$k]['current_item'] == $value['id_feature_value']) - $custom = false; + $custom = true; + foreach ($obj->getFeatures() as $tab_products) + if ($tab_products['id_feature'] == $tab_features['id_feature']) + $features[$k]['current_item'] = $tab_products['id_feature_value']; - if ($custom) - $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item']); + $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int)$tab_features['id_feature']); + if (count($features[$k]['featureValues'])) + foreach ($features[$k]['featureValues'] as $value) + if ($features[$k]['current_item'] == $value['id_feature_value']) + $custom = false; + + if ($custom) + $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item']); + } + + $data->assign('available_features', $features); + + $data->assign('product', $obj); + $data->assign('link', $this->context->link); + $data->assign('languages', $this->_languages); + $data->assign('default_form_language', $this->default_form_language); } - - $data->assign('available_features', $features); - - $data->assign('product', $obj); - $data->assign('link', $this->context->link); - $data->assign('languages', $this->_languages); - $data->assign('default_form_language', $this->default_form_language); + else + $this->displayWarning($this->l('You must save this product in this shop before adding features.')); } else - $this->displayWarning($this->l('You must save this product in this shop before adding features.')); + $this->displayWarning($this->l('You must save this product before adding features.')); } - else - $this->displayWarning($this->l('You must save this product before adding features.')); - $this->tpl_form_vars['custom_form'] = $data->fetch(); }