[-] FO: Search product listing should use the stock of default attribute as in category product listing
This commit is contained in:
1 parent
33781e0aad
commit
17a3d8ec76
1 file changed
+6
-3
+6
-3
@@ -281,9 +281,9 @@ class SearchCore
|
|||||||
$alias = '';
|
$alias = '';
|
||||||
if ($order_by == 'price')
|
if ($order_by == 'price')
|
||||||
$alias = 'product_shop.';
|
$alias = 'product_shop.';
|
||||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
|
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
|
||||||
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
|
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
|
||||||
image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.',
|
image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.', product_attribute_shop.`id_product_attribute`,
|
||||||
DATEDIFF(
|
DATEDIFF(
|
||||||
p.`date_add`,
|
p.`date_add`,
|
||||||
DATE_SUB(
|
DATE_SUB(
|
||||||
@@ -297,13 +297,16 @@ class SearchCore
|
|||||||
p.`id_product` = pl.`id_product`
|
p.`id_product` = pl.`id_product`
|
||||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||||
)
|
)
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`)
|
||||||
|
'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
|
||||||
|
'.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).'
|
||||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
|
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||||
'.Product::sqlStock('p', 0).'
|
|
||||||
WHERE p.`id_product` '.$product_pool.'
|
WHERE p.`id_product` '.$product_pool.'
|
||||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||||
|
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.id_shop='.(int)$context->shop->id.')
|
||||||
'.($order_by ? 'ORDER BY '.$alias.$order_by : '').($order_way ? ' '.$order_way : '').'
|
'.($order_by ? 'ORDER BY '.$alias.$order_by : '').($order_way ? ' '.$order_way : '').'
|
||||||
LIMIT '.(int)(($page_number - 1) * $page_size).','.(int)$page_size;
|
LIMIT '.(int)(($page_number - 1) * $page_size).','.(int)$page_size;
|
||||||
$result = $db->executeS($sql);
|
$result = $db->executeS($sql);
|
||||||
|
|||||||
Reference in new issue
Block a user