Пример #1
0
 public function addFeatureValue($tpl = null)
 {
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $helper = new JeproshopHelper();
     $this->assignRef('helper', $helper);
     $features = JeproshopFeatureModelFeature::getFeatures($this->context->language->lang_id);
     $this->assignRef('features', $features);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Пример #2
0
 private function initFeaturesForm()
 {
     if (!$this->context->controller->default_form_language) {
         $this->context->controller->getLanguages();
     }
     /*$data = $this->createTemplate($this->tpl_form);
       $data->assign('default_form_language', $this->default_form_language); */
     if (!JeproshopFeatureModelFeature::isFeaturePublished()) {
         $this->displayWarning($this->l('This feature has been disabled. ') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>');
     } else {
         if ($this->product->product_id) {
             if ($this->product_exists_in_shop) {
                 $features = JeproshopFeatureModelFeature::getFeatures($this->context->language->lang_id, JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP);
                 foreach ($features as $k => $feature) {
                     $features[$k]->current_item = false;
                     $features[$k]->val = array();
                     $custom = true;
                     foreach ($this->product->getFeatures() as $products) {
                         if ($products->feature_id == $features->feature_id) {
                             $features[$k]->current_item = $products->feature_value_id;
                         }
                     }
                     $features[$k]->featureValues = JeproshopFeatureValueModelFeatureValue::getFeatureValuesWithLang($this->context->language->lang_id, (int) $feature->feature_id);
                     if (count($features[$k]->featureValues)) {
                         foreach ($features[$k]->featureValues as $value) {
                             if ($features[$k]->current_item == $value->feature_value_id) {
                                 $custom = false;
                             }
                         }
                     }
                     if ($custom) {
                         $features[$k]->val = JeproshopFeatureValueModelFeatureValue::getFeatureValueLang($features[$k]->current_item);
                     }
                 }
                 $this->assignRef('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 the product in this shop before adding features.'));
             }
         } else {
             $this->displayWarning($this->l('You must save this product before adding features.'));
         }
     }
 }