[*] CORE : Remove duplicate SQL queries
This commit is contained in:
@@ -171,6 +171,8 @@ class WishList extends ObjectModel
|
||||
*/
|
||||
public static function getByIdCustomer($id_customer)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer))
|
||||
die (Tools::displayError());
|
||||
if (Shop::getContextShopID())
|
||||
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
|
||||
elseif (Shop::getContextShopGroupID())
|
||||
@@ -178,14 +180,18 @@ class WishList extends ObjectModel
|
||||
else
|
||||
$shop_restriction = '';
|
||||
|
||||
if (!Validate::isUnsignedId($id_customer))
|
||||
die (Tools::displayError());
|
||||
return (Db::getInstance()->executeS('
|
||||
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
|
||||
FROM `'._DB_PREFIX_.'wishlist` w
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
'.$shop_restriction.'
|
||||
ORDER BY w.`name` ASC'));
|
||||
$cache_id = __CLASS__.__FUNCTION__.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID();
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
|
||||
FROM `'._DB_PREFIX_.'wishlist` w
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
'.$shop_restriction.'
|
||||
ORDER BY w.`name` ASC');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
public static function refreshWishList($id_wishlist)
|
||||
|
||||
Reference in New Issue
Block a user