public function initFieldsetFeaturesDetachables() { $this->fields_form[2]['form'] = array('legend' => array('title' => $this->l('Optional features'), 'icon' => 'icon-puzzle-piece'), 'description' => $this->l('Some features can be disabled in order to improve performance.'), 'input' => array(array('type' => 'hidden', 'name' => 'features_detachables_up'), array('type' => 'switch', 'label' => $this->l('Combinations'), 'name' => 'combination', 'is_bool' => true, 'disabled' => Combination::isCurrentlyUsed(), 'values' => array(array('id' => 'combination_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'combination_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Combinations.'), 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null), array('type' => 'switch', 'label' => $this->l('Features'), 'name' => 'feature', 'is_bool' => true, 'values' => array(array('id' => 'feature_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'feature_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Features.')), array('type' => 'switch', 'label' => $this->l('Customer Groups'), 'name' => 'customer_group', 'is_bool' => true, 'disabled' => Group::isCurrentlyUsed(), 'values' => array(array('id' => 'group_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'group_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Customer Groups.'))), 'submit' => array('title' => $this->l('Save'))); $this->fields_value['combination'] = Combination::isFeatureActive(); $this->fields_value['feature'] = Feature::isFeatureActive(); $this->fields_value['customer_group'] = Group::isFeatureActive(); }
public function processFeatures() { if (!Feature::isFeatureActive()) { return; } if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) { // delete all objects $product->deleteFeatures(); // add new objects $languages = Language::getLanguages(false); foreach ($_POST as $key => $val) { if (preg_match('/^feature_([0-9]+)_value/i', $key, $match)) { if (!empty($val)) { foreach ($val as $v) { $product->addFeaturesToDB($match[1], $v); } } else { if ($default_value = $this->checkFeatures($languages, $match[1])) { $id_value = $product->addFeaturesToDB($match[1], 0, 1); foreach ($languages as $language) { if ($cust = Tools::getValue('custom_' . $match[1] . '_' . (int) $language['id_lang'])) { $product->addFeaturesCustomToDB($id_value, (int) $language['id_lang'], $cust); } else { $product->addFeaturesCustomToDB($id_value, (int) $language['id_lang'], $default_value); } } } } } } } else { $this->errors[] = Tools::displayError('A product must be created before adding features.'); } }
public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!Feature::isFeatureActive()) { return array(); } if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT name, value, pf.id_feature FROM ' . _DB_PREFIX_ . 'feature_product pf LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature f ON (f.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ') ' . Shop::addSqlAssociation('feature', 'f') . ' WHERE pf.id_product = ' . (int) $id_product . ' ORDER BY f.position ASC'); } $features = self::$_frontFeaturesCache[$id_product . '-' . $id_lang]; foreach ($features as &$feature) { if ($feature['id_feature'] == 9 && Context::getContext()->language->id != 1) { $feature['value'] = Tools::rus2translit($feature['value']); } } return $features; //return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; }
public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!Feature::isFeatureActive()) { return array(); } if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT name, GROUP_CONCAT(value ORDER BY fv.position SEPARATOR ", ") AS value, pf.id_feature FROM ' . _DB_PREFIX_ . 'feature_product pf LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature f ON f.id_feature = pf.id_feature LEFT JOIN ' . _DB_PREFIX_ . 'feature_value fv ON fv.id_feature_value = pf.id_feature_value ' . Shop::addSqlAssociation('feature', 'f') . ' WHERE pf.id_product = ' . (int) $id_product . ' GROUP BY name, pf.id_feature ORDER BY f.position ASC'); } return self::$_frontFeaturesCache[$id_product . '-' . $id_lang]; }
public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!Feature::isFeatureActive()) { return array(); } if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) { if (Module::isInstalled('blocklayered') && Module::isEnabled('blocklayered')) { Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096'); self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature`, `liflv`.`url_name`, `liflv`.`meta_title` FROM `' . _DB_PREFIX_ . 'feature_product` `pf` LEFT JOIN `' . _DB_PREFIX_ . 'feature_lang` `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ') LEFT JOIN `' . _DB_PREFIX_ . 'feature_value_lang` `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = ' . (int) $id_lang . ') LEFT JOIN `' . _DB_PREFIX_ . 'feature` `f` ON (`f`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value` LEFT JOIN `' . _DB_PREFIX_ . 'layered_indexable_feature_lang_value` `liflv` ON (`f`.`id_feature` = `liflv`.`id_feature` AND `liflv`.`id_lang` = ' . (int) $id_lang . ') ' . Shop::addSqlAssociation('feature', 'f') . ' WHERE pf.`id_product` = ' . (int) $id_product . ' GROUP BY `name`, pf.`id_feature` ORDER BY f.`position` ASC'); } else { Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096'); self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature` FROM ' . _DB_PREFIX_ . 'feature_product `pf` LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature `f` ON `f`.`id_feature` = `pf`.`id_feature` LEFT JOIN ' . _DB_PREFIX_ . 'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value` ' . Shop::addSqlAssociation('feature', 'f') . ' WHERE pf.id_product = ' . (int) $id_product . ' GROUP BY `name`, pf.`id_feature` ORDER BY f.`position` ASC'); } } return self::$_frontFeaturesCache[$id_product . '-' . $id_lang]; }
public static function getFeatures($db, $id_product, $id_lang) { if (!Feature::isFeatureActive()) { return ''; } $features = ''; $featuresArray = $db->executeS(' SELECT fvl.value FROM ' . _DB_PREFIX_ . 'feature_product fp LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fp.id_feature_value = fvl.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ') WHERE fp.id_product = ' . (int) $id_product); foreach ($featuresArray as $feature) { $features .= $feature['value'] . ' '; } return $features; }
public static function getFeaturesForComparison($list_ids_product, $id_lang) { if (!Feature::isFeatureActive()) { return false; } $ids = ''; foreach ($list_ids_product as $id) { $ids .= (int) $id . ','; } $ids = rtrim($ids, ','); if (empty($ids)) { return false; } return Db::getInstance()->executeS(' SELECT f.*, fl.* FROM `' . _DB_PREFIX_ . 'feature` f LEFT JOIN `' . _DB_PREFIX_ . 'feature_product` fp ON f.`id_feature` = fp.`id_feature` LEFT JOIN `' . _DB_PREFIX_ . 'feature_lang` fl ON f.`id_feature` = fl.`id_feature` WHERE fp.`id_product` IN (' . $ids . ') AND `id_lang` = ' . (int) $id_lang . ' GROUP BY f.`id_feature` ORDER BY f.`position` ASC '); }
public function initFormFeatures($obj) { if (!$this->default_form_language) { $this->getLanguages(); } $data = $this->createTemplate($this->tpl_form); $data->assign('default_form_language', $this->default_form_language); if (!Feature::isFeatureActive()) { $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 ($obj->id) { if ($this->product_exists_in_shop) { $features = Feature::getFeatures($this->context->language->id, Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP); foreach ($features as $k => $tab_features) { $features[$k]['current_item'] = false; $features[$k]['val'] = array(); $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']; } } $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); } 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.')); } } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
public function initFieldsetFeaturesDetachables() { $this->fields_form[2]['form'] = array('legend' => array('title' => $this->l('Optional features'), 'image' => '../img/admin/tab-plugins.gif'), 'desc' => $this->l('Some features can be disabled in order to improve performance.'), 'input' => array(array('type' => 'hidden', 'name' => 'features_detachables_up'), array('type' => 'radio', 'label' => $this->l('Combinations'), 'name' => 'combination', 'class' => 't', 'is_bool' => true, 'disabled' => Combination::isCurrentlyUsed(), 'values' => array(array('id' => 'combination_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'combination_0', 'value' => 0, 'label' => $this->l('No'))), 'desc' => $this->l('These features will be disabled')), array('type' => 'radio', 'label' => $this->l('Features'), 'name' => 'feature', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'feature_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'feature_0', 'value' => 0, 'label' => $this->l('No'))), 'desc' => $this->l('These features will be disabled')))); $this->fields_value['combination'] = Combination::isFeatureActive(); $this->fields_value['feature'] = Feature::isFeatureActive(); }
public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!Feature::isFeatureActive()) { return array(); } if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT name, value, pf.id_feature FROM ' . _DB_PREFIX_ . 'feature_product pf LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ') LEFT JOIN ' . _DB_PREFIX_ . 'feature f ON (f.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ') WHERE pf.id_product = ' . (int) $id_product . ' ORDER BY f.position ASC'); } return self::$_frontFeaturesCache[$id_product . '-' . $id_lang]; }
public function postProcess() { if (!Feature::isFeatureActive()) { return; } if ($this->table == 'feature_value' && ($this->action == 'save' || $this->action == 'delete' || $this->action == 'bulkDelete')) { Hook::exec('displayFeatureValuePostProcess', array('errors' => &$this->errors)); } else { Hook::exec('displayFeaturePostProcess', array('errors' => &$this->errors)); } // send errors as reference to allow displayFeaturePostProcess to stop saving process parent::postProcess(); if ($this->table == 'feature_value' && ($this->display == 'edit' || $this->display == 'add')) { $this->display = 'editFeatureValue'; } }
public function processFeatures() { if (!Feature::isFeatureActive()) { return; } if (!Validate::isLoadedObject($this->object)) { $this->errors[] = Tools::displayError("Product must be created before adding features."); return; } $this->object->deleteFeatures(); ${${"GLOBALS"}["emgichjdg"]} = Language::getLanguages(false); foreach ($_POST as ${${"GLOBALS"}["szxtvkafnfh"]} => ${${"GLOBALS"}["thcmvewqwmi"]}) { ${"GLOBALS"}["bgthjnfnf"] = "match"; if (preg_match("/^feature_([0-9]+)_value/i", ${${"GLOBALS"}["szxtvkafnfh"]}, ${${"GLOBALS"}["bgthjnfnf"]})) { $ugphilfazj = "val"; $ynigvj = "val"; if (${$ynigvj}) { $this->object->addFeaturesToDB(${${"GLOBALS"}["usgefpnkvmi"]}[1], ${$ugphilfazj}); } else { ${"GLOBALS"}["dfizdymik"] = "default_value"; ${"GLOBALS"}["olyvvjyq"] = "match"; ${"GLOBALS"}["eijymfuqqc"] = "languages"; if (${${"GLOBALS"}["dfizdymik"]} = $this->checkFeatures(${${"GLOBALS"}["eijymfuqqc"]}, ${${"GLOBALS"}["usgefpnkvmi"]}[1])) { ${"GLOBALS"}["gqqyeqxcmyfi"] = "languages"; $urlloqd = "language"; ${${"GLOBALS"}["nidhvjuji"]} = $this->object->addFeaturesToDB(${${"GLOBALS"}["usgefpnkvmi"]}[1], 0, 1); foreach (${${"GLOBALS"}["gqqyeqxcmyfi"]} as ${$urlloqd}) { $dzkybeesn = "cust"; ${"GLOBALS"}["ccydjt"] = "language"; ${"GLOBALS"}["codlywmdltx"] = "language"; ${"GLOBALS"}["ihigkmn"] = "cust"; if (${${"GLOBALS"}["ihigkmn"]} = Tools::getValue("custom_" . ${${"GLOBALS"}["usgefpnkvmi"]}[1] . "_" . (int) ${${"GLOBALS"}["exhdxhsxzdo"]}["id_lang"])) { $this->object->addFeaturesCustomToDB(${${"GLOBALS"}["nidhvjuji"]}, (int) ${${"GLOBALS"}["codlywmdltx"]}["id_lang"], ${$dzkybeesn}); } else { $this->object->addFeaturesCustomToDB(${${"GLOBALS"}["nidhvjuji"]}, (int) ${${"GLOBALS"}["ccydjt"]}["id_lang"], ${${"GLOBALS"}["ydddrdnk"]}); } } } else { ${${"GLOBALS"}["nidhvjuji"]} = $this->object->addFeaturesToDB(${${"GLOBALS"}["olyvvjyq"]}[1], 0, 1); } } } } }
/** * AdminController::initContent() override * @see AdminController::initContent() */ public function initContent() { if (Feature::isFeatureActive()) { // toolbar (save, cancel, new, ..) $this->initTabModuleList(); $this->initToolbar(); $this->initPageHeaderToolbar(); if ($this->display == 'edit' || $this->display == 'add') { if (!$this->loadObject(true)) { return; } $this->content .= $this->renderForm(); } else { if ($this->display == 'view') { // Some controllers use the view action without an object if ($this->className) { $this->loadObject(true); } $this->content .= $this->renderView(); } else { if (!$this->ajax) { // If a feature value was saved, we need to reset the values to display the list $this->setTypeFeature(); $this->content .= $this->renderList(); } } } } else { $url = '<a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performance') . '</a>'; $this->displayWarning(sprintf($this->l('This feature has been disabled. You can activate it here: %s.'), $url)); } $this->context->smarty->assign(array('content' => $this->content, 'url_post' => self::$currentIndex . '&token=' . $this->token, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn)); }