Syntax error, unexpected 'else' (T_ELSE)
Fermé
celine
-
Modifié le 2 août 2017 à 16:06
jordane45 Messages postés 38308 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 - 2 août 2017 à 17:50
jordane45 Messages postés 38308 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 - 2 août 2017 à 17:50
A voir également:
- Syntax error, unexpected 'else' (T_ELSE)
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Eespt technical error ✓ - Forum TNT / Satellite / Réception
- Error 0x80070643 - Accueil - Windows
- Cpu over temperature error - Forum Matériel & Système
- Fan error lenovo - Forum Refroidissement
3 réponses
jordane45
Messages postés
38308
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
24 novembre 2024
4 705
2 août 2017 à 16:07
2 août 2017 à 16:07
Tu ne nous a mis qu'une partie de ton code ....
Dans ton fichier pm_productsbyattributes.php ... quelle est la ligne 560 ?
Dans l'idéal tu nous montres également de la 520 à la 580....
Dans ton fichier pm_productsbyattributes.php ... quelle est la ligne 560 ?
Dans l'idéal tu nous montres également de la 520 à la 580....
Bonjour Jordane45,
Merci pour ta réponse rapide.
Voici le code complet :
Merci pour ta réponse rapide.
Voici le code complet :
<?php /** * @name Products by Attributes * @author Presta-Module.com <***@***> - http://www.presta-module.com * @copyright Presta-Module 2016 - http://www.presta-module.com * @version 1.0.5 * @psversion 1.5, 1.6 * @languages EN, FR * @category front_office_features * * ____ __ __ * | _ \ | \/ | * | |_) | | |\/| | * | __/ | | | | * |_| |_| |_| * * ************************************* ** Products by Attributes ** ************************************* */ if (!defined('_PS_VERSION_')) { exit; } include_once _PS_ROOT_DIR_ . '/modules/pm_productsbyattributes/ProductsByAttributesCoreClass.php'; class pm_productsbyattributes extends ProductsByAttributesCoreClass { protected $_defaultConfiguration = array( 'changeProductName' => true, 'hideCombinationsWithoutStock' => false, 'hideColorSquares' => true, 'addIDToAnchor' => true ); public function __construct() { $this->need_instance = 0; $this->name = 'pm_productsbyattributes'; $this->module_key = 'c44c197e40ce99724b7e5f6c631dacc4'; $this->author = 'Presta-Module'; $this->tab = 'front_office_features'; $this->version = '1.0.5'; $this->displayName = $this->l('Show Products by Attributes'); $this->description = $this->l('Show as many products you have attributes into your category pages'); parent::__construct(); } public function install() { if (!parent::install() || !$this->registerHook('actionProductListOverride') || !$this->registerHook('actionProductListModifier') || !$this->registerHook('displayHeader') ) { return false; } $this->_checkIfModuleIsUpdate(true, false, true); return true; } public function getContent() { if (Tools::getIsset('dismissRating') && Tools::getValue('dismissRating')) { if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { Configuration::updateGlobalValue('PM_'.ProductsByAttributesCoreClass::$_module_prefix.'_DISMISS_RATING', 1); } else { Configuration::updateValue('PM_'.ProductsByAttributesCoreClass::$_module_prefix.'_DISMISS_RATING', 1); } die; } else { if (Tools::getIsset('submitModuleConfiguration') && Tools::isSubmit('submitModuleConfiguration')) { $this->_postProcess(); } parent::getContent(); if (Tools::getValue('makeUpdate')) { $this->_checkIfModuleIsUpdate(true); } if (!$this->_checkIfModuleIsUpdate(false)) { $this->context->controller->warnings [] = ' <p>' . $this->l('We have detected that you installed a new version of the module on your shop') . '</p> <p style="text-align: center"><a href="' . $this->_base_config_url . '&makeUpdate=1" class="button">' . $this->l('Please click here in order to finish the installation process') . '</a></p>'; return; } $this->_showRating(true); $this->_html .= '<div id="pm-module-configuration-wrapper">'; $this->_html .= '<div id="spa-config-tab">'; $this->_html .= '<ul> <li><a href="#spa-configuration" rel="nofollow noopener noreferrer" target="_blank">'. $this->l('Configuration') .'</a></li> </ul>'; $this->_html .= '<div id="spa-configuration">'; $this->_renderConfigurationForm(); $this->_html .= '</div>'; $this->_html .= '</div><!-- end spa-config-tab -->'; $this->_html .= '<script>$(function() { $( "#spa-config-tab" ).tabs(); });</script>'; $this->_html .= '</div><!-- end pm-module-configuration-wrapper -->'; $this->_displaySupport(); return $this->_html; } } private function _postProcess() { if (Tools::getIsset('submitModuleConfiguration') && Tools::isSubmit('submitModuleConfiguration')) { $config = $this->_getModuleConfiguration(); foreach (array('changeProductName', 'hideCombinationsWithoutStock', 'hideColorSquares', 'addIDToAnchor') as $configKey) { $config[$configKey] = (bool)Tools::getValue($configKey); } foreach (array('selectedGroups') as $configKey) { $config[$configKey] = (int)Tools::getValue($configKey); } $this->_setModuleConfiguration($config); $this->context->controller->confirmations[] = $this->l('Module configuration successfully saved'); } } private function _renderConfigurationForm() { $config = $this->_getModuleConfiguration(); $this->_startForm(array('id' => 'formGlobalOptions', 'iframetarget' => false, 'target' => '_self')); if (version_compare(_PS_VERSION_, '1.6.0.0', '<') && Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')) { $this->context->controller->warnings[] = '<p>' . $this->l('We have detected that you show the "Add to cart" button if the product have somes attributes. Due to your theme, the "Add to cart" link may be not related to the splitted attribute of the product') . '</p>'; } $this->_html .= '<h4>'. $this->l('Settings') .'</h4>'; $this->_displaySelect(array( 'obj' => $config, 'key' => 'selectedGroups', 'isarray', true, 'options' => $this->_getAttributeGroupOptions(), 'onchange' => 'display_hide_squares_color();', 'tips' => $this->l('You can split only one attribute group at once'), 'label' => $this->l('Attributes Group to split'))); if (version_compare(_PS_VERSION_, '1.6.0.0', '>=')) { $sql = 'SELECT `id_attribute_group` FROM `'._DB_PREFIX_.'attribute_group` WHERE `is_color_group` = 1'; $groups = DB::getInstance()->ExecuteS($sql); $this->_html .= "<script type=\"text/javascript\">"; $this->_html .= "var color_groups = ["; if (is_array($groups)) { foreach ($groups as $group) { $this->_html .= $group['id_attribute_group'].', '; } $this->_html = Tools::substr($this->_html, 0, -2); } $this->_html .= "]; </script>"; $this->_displayInputActive(array( 'obj' => $config, 'key_active' => 'hideColorSquares', 'key_db' => 'hideColorSquares', 'defaultvalue' => $this->_defaultConfiguration['hideColorSquares'], 'tips' => $this->l('If you choose an attribute group which is a color group, you can decide to hide the color squares into the product list'), 'label' => $this->l('Hide color square ?'))); } else { $this->_html .= "<script type=\"text/javascript\">"; $this->_html .= "var color_groups = []"; $this->_html .= "</script>"; } $this->_displayInputActive(array( 'obj' => $config, 'key_active' => 'changeProductName', 'key_db' => 'changeProductName', 'defaultvalue' => $this->_defaultConfiguration['changeProductName'], 'tips' => $this->l('If enabled, will change the product name with the split attribute name. (e.g.: "Printed Dress" with red and green color becomre "Printed Dress - Red" and "Printed Dress - Green")'), 'label' => $this->l('Change product name ?'))); $input = array( 'obj' => $config, 'key_active' => 'hideCombinationsWithoutStock', 'key_db' => 'hideCombinationsWithoutStock', 'defaultvalue' => $this->_defaultConfiguration['hideCombinationsWithoutStock'], 'label' => $this->l('Hide combinations without stock?')); if (!Configuration::get('PS_DISP_UNAVAILABLE_ATTR')) { $input['obj']['hideCombinationsWithoutStock'] = true; $input['disabled'] = true; } $this->_displayInputActive($input); if (!Configuration::get('PS_DISP_UNAVAILABLE_ATTR')) { if (version_compare(_PS_VERSION_, '1.6.1.0', '>=')) { $this->_html .= $this->displayWarning('<p>' . $this->l('We have detected that you don\'t show the unavailable attributes on a product page. The splitted product without stocks will not be shown') . '</p>'); } else { $this->context->controller->warnings[] = '<p>' . $this->l('We have detected that you don\'t show the unavailable attributes on a product page. The splitted product without stocks will not be shown') . '</p>'; } } $this->_html .= '<h4>'. $this->l('Backward settings') .'</h4>'; $this->_displayInputActive(array( 'obj' => $config, 'key_active' => 'addIDToAnchor', 'key_db' => 'addIDToAnchor', 'defaultvalue' => $this->_defaultConfiguration['addIDToAnchor'], 'tips' => $this->l('If you theme is not compliant with ID in anchor URL, you need to disable this'), 'label' => $this->l('Add ID to anchor ?'))); $this->_displaySubmit($this->l(' Save '), 'submitModuleConfiguration'); $this->_endForm(array('id' => 'formGlobalOptions', 'includehtmlatend' => true)); } public function hookActionProductListOverride($params) { $conf = $this->_getModuleConfiguration(); if (!Combination::isFeatureActive() || !isset($conf['selectedGroups'])) { $params['hookExecuted'] = false; } else { if (isset($params['module']) && $params['module'] == 'pm_advancedsearch4') { $do_split = true; if (isset($params['selected_criteria_groups_type']) && is_array($params['selected_criteria_groups_type'])) { foreach ($params['selected_criteria_groups_type'] as $id_criterion_group_linked => $selected_criteria_group_type) { if ((int)$selected_criteria_group_type['id_criterion_group_linked'] == (int)$conf['selectedGroups']) { if ((bool)!$selected_criteria_group_type['is_multicriteria']) { $do_split = false; } else { $params['splitOnSplitGroup'] = (int)$id_criterion_group_linked; $do_split = true; } break; } } } if ($do_split) { $this->splitProductsListOfSearchResults($params); $this->splitProductsList($params['catProducts']); } $params['hookExecuted'] = $do_split; $params['splitDone'] = $do_split; } else { $module = Module::getInstanceByName('blocklayered'); if (is_object($module) && $module->active) { $params['hookExecuted'] = false; } else { $id_category = (int)Tools::getValue('id_category'); if (!$id_category || !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } $this->hideColorSquares(); $params['nbProducts'] = $this->getCategoryProducts((int)$id_category, null, null, null, $this->context->controller->orderBy, $this->context->controller->orderWay, true); $this->context->controller->pagination((int)$params['nbProducts']); $params['catProducts'] = $this->getCategoryProducts((int)$id_category, (int)$this->context->language->id, (int)$this->context->controller->p, (int)$this->context->controller->n, $this->context->controller->orderBy, $this->context->controller->orderWay); $this->splitProductsList($params['catProducts']); $params['hookExecuted'] = true; } } } } public function hookActionProductListModifier($params) { $conf = $this->_getModuleConfiguration(); if (!Combination::isFeatureActive() || !isset($conf['selectedGroups'])) { return false; } $module = Module::getInstanceByName('blocklayered'); if (is_object($module) && $module->active) { $params['module'] = 'blocklayered'; $do_split = true; if ($do_split) { $this->hideColorSquares(); $params['catProducts'] = $params['cat_products']; $params['nbProducts'] = $params['nb_products']; $this->splitProductsListOfSearchResults($params); $this->splitProductsList($params['catProducts']); $params['add_colors_to_product_list'] = false; $params['cat_products'] = $params['catProducts']; $params['nb_products'] = $params['nbProducts']; } } } public function splitProductsListOfSearchResults(&$params) { $conf = $this->_getModuleConfiguration(); if (isset($params['module']) && $params['module'] == 'pm_advancedsearch4') { $attributes_selected = array(); foreach ($params['selected_criterion'] as $id_criterion_group => $selected_criterions) { foreach ($selected_criterions as $selected_criterion) { $doContinue = true; if ($params['selected_criteria_groups_type'][(int)$id_criterion_group]['criterion_group_type'] == 'attribute') { if (isset($params['splitOnSplitGroup']) && $params['splitOnSplitGroup']) { if ((int)$id_criterion_group == $params['splitOnSplitGroup']) { $doContinue = true; } else { $doContinue = false; } } if ($doContinue) { $attribute_selected = $selected_criterion; $id_search = (int)Tools::getValue('id_search'); if (!$id_search) { $id_search = (int)Tools::getValue('id_seo_id_search'); } $sql = 'SELECT visible FROM '._DB_PREFIX_.'pm_advancedsearch_criterion_group_'.(int)$id_search.' WHERE id_criterion_group = '.(int)$id_criterion_group; $is_visible = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($is_visible) { $sql = 'SELECT id_criterion_linked FROM '._DB_PREFIX_.'pm_advancedsearch_criterion_'.(int)$id_search.'_link WHERE id_criterion = '.(int)$selected_criterion; $attribute_selected = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); $attributes_selected[] = (int)$attribute_selected; } } } } } } else if (isset($params['module']) && $params['module'] == 'blocklayered') { $attributes_selected = array(); foreach ($_GET as $key => $value) { $doContinue = true; if (Tools::substr($key, 0, 27) == 'layered_id_attribute_group_') { $tmp_tab = explode('_', $value); $attribute_selected = (int)$tmp_tab[0]; $id_criterion_group = (int)$tmp_tab[1]; if ((int)$id_criterion_group == (int)$conf['selectedGroups']) { $doContinue = true; } else { $doContinue = false; } if ($doContinue) { $attributes_selected[] = (int)$attribute_selected; } } } } $temp = array(); $already_done = array(); foreach ($params['catProducts'] as &$product) { $obj = new Product((int)$product['id_product']); $almost_one = false; $combinations = $obj->getAttributeCombinations((int)$this->context->language->id); if (is_array($combinations) && count($combinations)) { foreach ($combinations as $combination) { if (!isset($already_done[(int)$combination['id_product'].'_'.(int)$combination['id_attribute']]) && (int)$combination['id_attribute_group'] == (int)$conf['selectedGroups']) { if (isset($params['module']) && ($params['module'] == 'pm_advancedsearch4' || $params['module'] == 'blocklayered') && count($attributes_selected) > 0) { $is_match = false; $doContinue = false; $product_attributes = $obj->getAttributeCombinationsById((int)$combination['id_product_attribute'], (int)$this->context->language->id); foreach ($product_attributes as $product_attribute) { if (in_array($product_attribute['id_attribute'], $attributes_selected)) { $is_match = true; $doContinue = true; } } } else { $is_match = true; $doContinue = true; } if (!Configuration::get('PS_DISP_UNAVAILABLE_ATTR') && (int)$combination['quantity'] <= 0) { $doContinue = false; } if ($doContinue && (!(int)$conf['hideCombinationsWithoutStock'] || ((int)$conf['hideCombinationsWithoutStock'] && $is_match && (int)$combination['quantity'] > 0))) { $product['pai_id_product_attribute'] = (int)$combination['id_product_attribute']; $product['cache_default_attribute'] = (int)$combination['id_product_attribute']; $product['product_name'] = $product['name'].' - '.$combination['attribute_name']; $product['quantity_sql'] = $combination['quantity']; $product['is_color_group'] = (bool)$combination['is_color_group']; $temp[] = $product; $almost_one = true; $already_done[(int)$combination['id_product'].'_'.(int)$combination['id_attribute']] = true; } } } } if (!$almost_one) { $product['pai_id_product_attribute'] = (int)$product['id_product_attribute']; $product['product_name'] = $product['name']; $product['quantity_sql'] = $product['quantity']; $product['is_color_group'] = false; $temp[] = $product; } } $params['nbProducts'] = (int)count($temp); if (isset($params['products_per_page'])) { $params['catProducts'] = array_slice($temp, (int)$params['products_per_page'] * ((int)Tools::getValue('p', 1) - 1), Tools::getValue('n', (int)$params['products_per_page'])); } else { $params['catProducts'] = $temp; } } public function getCategoryProducts($id_category, $id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $fullTree = false) { $context = Context::getContext(); if (!$id_lang) { $id_lang = (int)$this->context->language->id; } $conf = $this->_getModuleConfiguration(); $front = in_array($context->controller->controller_type, array('front', 'modulefront')); $id_supplier = (int)Tools::getValue('id_supplier'); if ($get_total) { $sql = ' SELECT COUNT(total) as total FROM ( ( SELECT COUNT(p.`id_product`) as total FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category` AND c.nleft >= '.(int)$context->controller->getCategory()->nleft.' AND c.nright <= '.(int)$context->controller->getCategory()->nright.') LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` AND (a.`id_attribute_group` = '.(int)$conf['selectedGroups'].')' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' ) .Product::sqlStock('p', 'pa').' WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND product_shop.`active` = 1 AND cp.`id_category` '.(!$fullTree ? '= '.(int)$id_category : ' > 0') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .($conf['hideCombinationsWithoutStock'] ? ' AND stock.quantity > 0' : '') .' GROUP BY a.`id_attribute`, cp.`id_product` ) UNION ALL ( SELECT COUNT(p.`id_product`) as total FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category` AND c.nleft >= '.(int)$context->controller->getCategory()->nleft.' AND c.nright <= '.(int)$context->controller->getCategory()->nright.') LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` AND (a.`id_attribute_group` = '.(int)$conf['selectedGroups'].')' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' ) .Product::sqlStock('p', 0).' WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND product_shop.`active` = 1 AND cp.`id_category` '.(!$fullTree ? '= '.(int)$id_category : ' > 0') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .' GROUP BY cp.`id_product` HAVING COUNT(a.`id_attribute`) = 0 ) ) total_query'; return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } $nb_days_new_product = Configuration::get('PS_NB_DAYS_NEW_PRODUCT'); if (!Validate::isUnsignedInt($nb_days_new_product)) { $nb_days_new_product = 20; } $order_by = Validate::isOrderBy($order_by) ? Tools::strtolower($order_by) : 'position'; $order_way = Validate::isOrderWay($order_way) ? Tools::strtoupper($order_way) : 'ASC'; $need_order_value_field = null; if ($order_by == 'date_add' || $order_by == 'date_upd') { $need_order_value_field = true; $order_by_prefix = 'p'; } $sql = '(SELECT '.(!empty($need_order_value_field) ? $order_by_prefix.'.'.bqSQL($order_by).' AS `order_value`, ' : '').'p.*, product_shop.*, pl.`name`, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, IFNULL(stock.quantity, 0) AS quantity_sql, ' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'IFNULL(product_attribute_shop.id_product_attribute, 0) AS id_product_attribute' : 'IFNULL(pa.`id_product_attribute`, 0) AS id_product_attribute').', product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, image_shop.`id_image` id_image, il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB("'.date('Y-m-d').' 00:00:00", INTERVAL '.(int)$nb_days_new_product.' DAY)) > 0 AS new, product_shop.price AS orderprice, cp.`position`, a.`position` as `position_attribute`, pa.`id_product_attribute` as pai_id_product_attribute, '.($conf['changeProductName'] ? 'CONCAT(pl.`name`, " - ", al.`name`)' : 'pl.`name`').' as product_name, ag.`is_color_group`, CONCAT_WS("-", "spa", "a", p.id_product, pa.id_product_attribute) as `id_product_pack` FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category` AND c.nleft >= '.(int)$context->controller->getCategory()->nleft.' AND c.nright <= '.(int)$context->controller->getCategory()->nright.') LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') ).' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product`'.($conf['hideCombinationsWithoutStock'] && !Configuration::get('PS_DISP_UNAVAILABLE_ATTR') ? ' AND pa.`default_on` = 1' : '').' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` AND (a.`id_attribute_group` = '.(int)$conf['selectedGroups'].') LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' ) .Product::sqlStock('p', 'pa').' WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND product_shop.`active` = 1 AND cp.`id_category` '.(!$fullTree ? '= '.(int)$id_category : ' > 0') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .($conf['hideCombinationsWithoutStock'] || !Configuration::get('PS_DISP_UNAVAILABLE_ATTR') ? ' AND stock.quantity > 0' : '') .' GROUP BY a.`id_attribute`, cp.`id_product`)'; $sql .= ' UNION ALL '; $sql .= '(SELECT '.(!empty($need_order_value_field) ? $order_by_prefix.'.'.bqSQL($order_by).' AS `order_value`, ' : '').'p.*, product_shop.*, pl.`name`, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, IFNULL(stock.quantity, 0) AS quantity_sql, ' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'IFNULL(product_attribute_shop.id_product_attribute, 0) AS id_product_attribute' : 'IFNULL(pa.`id_product_attribute`, 0) AS id_product_attribute').', product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, image_shop.`id_image` id_image, il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB("'.date('Y-m-d').' 00:00:00", INTERVAL '.(int)$nb_days_new_product.' DAY)) > 0 AS new, product_shop.price AS orderprice, cp.`position`, a.`position` as `position_attribute`, pa.`id_product_attribute` as pai_id_product_attribute, pl.`name` as product_name, "0" as `is_color_group`, "spa-nochanges" as `id_product_pack` FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category` AND c.nleft >= '.(int)$context->controller->getCategory()->nleft.' AND c.nright <= '.(int)$context->controller->getCategory()->nright.') LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') ).' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product` AND pa.`default_on` = 1 LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` AND (a.`id_attribute_group` = '.(int)$conf['selectedGroups'].')' .(version_compare(_PS_VERSION_, '1.6.1.0', '>=') ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' : 'LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop ON (product_attribute_shop.`id_product_attribute` = pac.`id_product_attribute` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop='.(int)$context->shop->id.')' ) .Product::sqlStock('p', 0).' WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND product_shop.`active` = 1 AND cp.`id_category` '.(!$fullTree ? '= '.(int)$id_category : ' > 0') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .' GROUP BY cp.id_product HAVING COUNT(a.`id_attribute`) = 0 )'; if ($p < 1) { $p = 1; } $order_by_prefix = false; $order_by2 = false; if ($order_by == 'id_product') { $order_by_prefix = 'p'; } else if ($order_by == 'date_add' || $order_by == 'date_upd') { $order_by = 'order_value'; } else if ($order_by == 'name') { $order_by = 'product_name'; } else if ($order_by == 'manufacturer' || $order_by == 'manufacturer_name') { $order_by = 'manufacturer_name'; } else if ($order_by == 'quantity') { $order_by = 'quantity_sql'; } else if ($order_by == 'price') { $order_by = 'orderprice'; } else if ($order_by == 'position') { $order_by2 = 'position_attribute'; } $sql .= ' ORDER BY '.(!empty($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.bqSQL($order_by).'`'.(!empty($order_by2) ? ', `'.bqSQL($order_by2).'`' : '').' '.pSQL($order_way).' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false); if (!$result) { return array(); } if ($order_by == 'orderprice') { Tools::orderbyPrice($result, $order_way); } return Product::getProductsProperties($id_lang, $result); } public function splitProductsList(&$products) { $conf = $this->_getModuleConfiguration(); $combined = array(); foreach ($products as $p => &$product) { if (isset($_POST['id_product_pack'])) { $product = $_POST['spa-nochanges'];} { $combined[(int)$product['id_product']] = true; $product['id_product_attribute'] = (int)$product['pai_id_product_attribute']; $product['cache_default_attribute'] = (int)$product['pai_id_product_attribute']; $product['quantity'] = (int)$product['quantity_sql']; $product['id_product_pack'] = 'spa-'.$product['id_product'].'-'.$product['id_product_attribute']; $product = Product::getProductProperties((int)Context::getContext()->language->id, $product); if ($conf['changeProductName']) { $product['name'] = $product['product_name']; } if (!isset($product['category']) || $product['category'] == '') { $product['category'] = Category::getLinkRewrite((int)$product['id_category_default'], (int)$this->context->language->id); } $add_anchor = true; if (isset($conf['addIDToAnchor']) && !$conf['addIDToAnchor']) { $add_anchor = false; } $product['link'] = $this->context->link->getProductLink((int)$product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], null, null, (int)$product['pai_id_product_attribute'], Configuration::get('PS_REWRITING_SETTINGS'), false, $add_anchor); $combination_image = self::getBestImageAttribute((int)$this->context->shop->id, (int)$this->context->language->id, (int)$product['id_product'], (int)$product['pai_id_product_attribute']); if (isset($combination_image['id_image'])) { $product['id_image'] = (int)$combination_image['id_image']; } else { $cover = Product::getCover((int)$product['id_product']); $product['id_image'] = (int)$cover['id_image']; } $product['attribute_image'] = (int)$product['id_image']; $product['id_image'] = Product::defineProductImage($product, (int)$this->context->language->id); }else{ if (isset($combined[(int)$product['id_product']])) { unlink($products[(int)$p]); } } } return $products; } public static function getBestImageAttribute($id_shop, $id_lang, $id_product, $id_product_attribute) { if (method_exists('Image', 'getBestImageAttribute')) { return Image::getBestImageAttribute((int)$id_shop, (int)$id_lang, (int)$id_product, (int)$id_product_attribute); } else { $cache_id = 'Image::getBestImageAttribute'.'-'.(int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_lang.'-'.(int)$id_shop; if (!Cache::isStored($cache_id)) { $row = Db::getInstance()->getRow(' SELECT image_shop.`id_image` id_image, il.`legend` FROM `'._DB_PREFIX_.'image` i INNER JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.id_shop = '.(int)$id_shop.') INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai ON (pai.`id_image` = i.`id_image` AND pai.`id_product_attribute` = '.(int)$id_product_attribute.') LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') WHERE i.`id_product` = '.(int)$id_product.' ORDER BY i.`position` ASC'); Cache::store($cache_id, $row); } else { $row = Cache::retrieve($cache_id); } return $row; } } protected function hideColorSquares() { $conf = $this->_getModuleConfiguration(); if (isset($conf['hideColorSquares']) && $conf['hideColorSquares']) { $attribute_group = new AttributeGroup((int)$conf['selectedGroups']); if ($attribute_group->is_color_group) { $this->context->controller->addJS($this->_path . 'views/js/hide-color-list-container.js'); } } } protected function _getAttributeGroupOptions() { $groups = AttributeGroup::getAttributesGroups((int)$this->context->language->id); $return = array(); foreach ($groups as $group) { $return[$group['id_attribute_group']] = $group['name']; } $module = Module::getInstanceByName('pm_advancedpack'); if (is_object($module) && isset($return[(int)AdvancedPack::getPackAttributeGroupId()])) { unset($return[(int)AdvancedPack::getPackAttributeGroupId()]); } return $return; } public function getHideColorSquaresConf() { $conf = $this->_getModuleConfiguration(); if (isset($conf['hideColorSquares']) && $conf['hideColorSquares']) { return true; } else { return false; } } public function hookDisplayHeader() { $module = Module::getInstanceByName('blocklayered'); if (is_object($module) && $module->active) { return '<style type="text/css">.product-count { visibility: hidden; }</style>'; } } }
jordane45
Messages postés
38308
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
24 novembre 2024
4 705
2 août 2017 à 17:50
2 août 2017 à 17:50
Vers la ligne 540
if (isset($_POST['id_product_pack'])) { $product = $_POST['spa-nochanges'];} {