// Moved a condition/function from SQL to PHP.
This commit is contained in:
1 parent
6531572c15
commit
eff81dfe05
1 file changed
+5
-27
+5
-27
@@ -1978,13 +1978,7 @@ class ProductCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
'.Shop::addSqlAssociation('product', 'p').'
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
WHERE product_shop.`active` = 1
|
WHERE product_shop.`active` = 1
|
||||||
AND DATEDIFF(
|
AND product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"
|
||||||
product_shop.`date_add`,
|
|
||||||
DATE_SUB(
|
|
||||||
NOW(),
|
|
||||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
|
||||||
)
|
|
||||||
) > 0
|
|
||||||
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
|
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
@@ -1999,13 +1993,7 @@ class ProductCore extends ObjectModel
|
|||||||
$sql->select(
|
$sql->select(
|
||||||
'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
||||||
DATEDIFF(
|
product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new'
|
||||||
product_shop.`date_add`,
|
|
||||||
DATE_SUB(
|
|
||||||
NOW(),
|
|
||||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
|
||||||
)
|
|
||||||
) > 0 AS new'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql->from('product', 'p');
|
$sql->from('product', 'p');
|
||||||
@@ -2020,25 +2008,15 @@ class ProductCore extends ObjectModel
|
|||||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||||
|
|
||||||
$sql->where('product_shop.`active` = 1');
|
$sql->where('product_shop.`active` = 1');
|
||||||
|
|
||||||
if ($front)
|
if ($front)
|
||||||
$sql->where('product_shop.`visibility` IN ("both", "catalog")');
|
$sql->where('product_shop.`visibility` IN ("both", "catalog")');
|
||||||
$sql->where('
|
$sql->where('product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"');
|
||||||
DATEDIFF(
|
|
||||||
product_shop.`date_add`,
|
|
||||||
DATE_SUB(
|
|
||||||
NOW(),
|
|
||||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
|
||||||
)
|
|
||||||
) > 0'
|
|
||||||
);
|
|
||||||
|
|
||||||
$sql->where('p.`id_product` IN (
|
$sql->where('p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||||
WHERE cg.`id_group` '.$sql_groups.')'
|
WHERE cg.`id_group` '.$sql_groups.'
|
||||||
);
|
)');
|
||||||
$sql->groupBy('product_shop.id_product');
|
$sql->groupBy('product_shop.id_product');
|
||||||
|
|
||||||
$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
|
$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
|
||||||
|
|||||||
Reference in new issue
Block a user