// Fix join between product_attribute and product_attribute_shop on getproducts methods
This commit is contained in:
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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")' : '')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user