diff --git a/classes/Cart.php b/classes/Cart.php index 1bc7b1961..b1cfae764 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -457,7 +457,7 @@ class CartCore extends ObjectModel '); $sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`'); - $sql->join(Shop::addSqlAssociation('product_attribute', 'pa')); + $sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false)); $sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`'); $sql->leftJoin('image_lang', 'il', 'il.id_image = pai.id_image AND il.id_lang = '.(int)$this->id_lang); } diff --git a/classes/Category.php b/classes/Category.php index c29de9495..a2b576022 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -647,7 +647,7 @@ class CategoryCore extends ObjectModel ON p.`id_product` = cp.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) - '.Shop::addSqlAssociation('product_attribute', 'pa').' + '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').' '.Shop::addSqlAssociation('product', 'p').' '.Product::sqlStock('p', 'pa', false, $context->shop).' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl @@ -675,7 +675,6 @@ class CategoryCore extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = '.(int)Context::getContext()->shop->id.' - AND product_attribute_shop.default_on = 1 AND cp.`id_category` = '.(int)$this->id .($active ? ' AND product_shop.`active` = 1' : '') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php index b0ef20629..68a9f911f 100644 --- a/classes/Manufacturer.php +++ b/classes/Manufacturer.php @@ -337,7 +337,7 @@ class ManufacturerCore extends ObjectModel '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) - '.Shop::addSqlAssociation('product_attribute', 'pa').' + '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').') LEFT JOIN `'._DB_PREFIX_.'image` i @@ -359,7 +359,6 @@ class ManufacturerCore extends ObjectModel WHERE p.`id_manufacturer` = '.(int)$id_manufacturer.' '.($active ? ' AND product_shop.`active` = 1' : '').' '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' - AND product_attribute_shop.`default_on` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 73b9c8f35..07487d153 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -730,10 +730,10 @@ class ShopCore extends ObjectModel * @param string $table Table name (E.g. product, module, etc.) * @param string $alias Alias of table * @param bool $inner_join Use or not INNER JOIN - * @param Context $context + * @param string $on * @return string */ - public static function addSqlAssociation($table, $alias, $inner_join = true) + public static function addSqlAssociation($table, $alias, $inner_join = true, $on = null) { $table_alias = $table.'_shop'; if (strpos($table, '.') !== false) @@ -745,7 +745,8 @@ class ShopCore extends ObjectModel $sql = (($inner_join) ? ' INNER' : ' LEFT').' JOIN '._DB_PREFIX_.$table.'_shop '.$table_alias.' ON '.$table_alias.'.id_'.$table.' = '.$alias.'.id_'.$table.' - AND '.$table_alias.'.id_shop IN('.implode(', ', Shop::getContextListShopID()).') '; + AND '.$table_alias.'.id_shop IN('.implode(', ', Shop::getContextListShopID()).') ' + .(($on) ? ' AND '.$on : ''); return $sql; }