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); }
public static function getFeatures($db, $product_id, $lang_id) { if (!JeproshopFeatureModelFeature::isFeaturePublished()) { return ''; } $features = ''; $query = "SELECT feature_value_lang.value FROM " . $db->quoteName('#__jeproshop_product_feature') . " AS product_feature LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_feature_value_lang') . " AS feature_value_lang ON (product_feature.feature_value_id = "; $query .= "feature_value_lang.feature_value_id AND feature_value_lang.lang_id = " . (int) $lang_id . ") WHERE product_feature."; $query .= "product_id = " . (int) $product_id; $featuresArray = $db->loadObjectList(); foreach ($featuresArray as $feature) { $features .= $feature->value . ' '; } return $features; }
public static function getFrontStaticFeatures($lang_id, $product_id) { $db = JFactory::getDBO(); if (!JeproshopFeatureModelFeature::isFeaturePublished()) { return array(); } if (!array_key_exists($product_id . '_' . $lang_id, self::$_frontFeaturesCache)) { $query = "SELECT name, value, product_feature.feature_id FROM " . $db->quoteName('#__jeproshop_product_feature') . " AS product_feature\tLEFT JOIN "; $query .= $db->quoteName('#__jeproshop_feature_lang') . " AS feature_lang ON (feature_lang.feature_id = product_feature.feature_id AND feature_lang."; $query .= "lang_id = " . (int) $lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_feature_value_lang') . " AS feature_value_lang ON (feature_value_lang."; $query .= "feature_value_id = product_feature.feature_value_id AND feature_value_lang.lang_id = " . (int) $lang_id . ") LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_feature') . " AS feature ON (feature.feature_id = product_feature.feature_id AND feature_lang.lang_id = "; $query .= (int) $lang_id . ") " . JeproshopShopModelShop::addSqlAssociation('feature') . " WHERE product_feature.product_id = " . (int) $product_id; $query .= "\tORDER BY feature.position ASC"; $db->setQuery($query); self::$_frontFeaturesCache[$product_id . '_' . $lang_id] = $db->loadObjectList(); } return self::$_frontFeaturesCache[$product_id . '_' . $lang_id]; }
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.')); } } }
public static function getStaticFeatures($product_id) { if (!JeproshopFeatureModelFeature::isFeaturePublished()) { return array(); } if (!array_key_exists($product_id, self::$_cacheFeatures)) { $db = JFactory::getDBO(); $query = "SELECT product_feature.feature_id, product_feature.product_id, product_feature.feature_value_id, custom FROM "; $query .= $db->quoteName('#__jeproshop_product_feature') . " AS product_feature LEFT JOIN " . $db->quoteName('#__jeproshop_feature_value'); $query .= " AS feature_value ON (product_feature.feature_value_id = feature_value.feature_value_id ) WHERE "; $query .= $db->quoteName('product_id') . " = " . (int) $product_id; $db->setQuery($query); self::$_cacheFeatures[$product_id] = $db->loadObjectList(); } return self::$_cacheFeatures[$product_id]; }