[*] FO : Cache on getDiscountsCustomer, follow up https://github.com/PrestaShop/PrestaShop/pull/960
This commit is contained in:
+10
-6
@@ -368,12 +368,16 @@ class CartCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!CartRule::isFeatureActive())
|
if (!CartRule::isFeatureActive())
|
||||||
return 0;
|
return 0;
|
||||||
|
$cache_id = __CLASS__.__FUNCTION__.(int)$this->id.'-'.(int)$id_cart_rule;
|
||||||
return Db::getInstance()->getValue('
|
if (!Cache::isStored($cache_id))
|
||||||
SELECT COUNT(*)
|
{
|
||||||
FROM `'._DB_PREFIX_.'cart_cart_rule`
|
$result = (int)Db::getInstance()->getValue('
|
||||||
WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id
|
SELECT COUNT(*)
|
||||||
);
|
FROM `'._DB_PREFIX_.'cart_cart_rule`
|
||||||
|
WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id);
|
||||||
|
Cache::store($cache_id, $result);
|
||||||
|
}
|
||||||
|
return Cache::retrieve($cache_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastProduct()
|
public function getLastProduct()
|
||||||
|
|||||||
+11
-5
@@ -721,11 +721,17 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
public static function getDiscountsCustomer($id_customer, $id_cart_rule)
|
public static function getDiscountsCustomer($id_customer, $id_cart_rule)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->getValue('
|
$cache_id = __CLASS__.__FUNCTION__.(int)$id_customer.'-'.(int)$id_cart_rule;
|
||||||
SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
|
if (!Cache::isStored($cache_id))
|
||||||
LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
|
{
|
||||||
WHERE o.id_customer = '.(int)$id_customer.'
|
$result = (int)Db::getInstance()->getValue('
|
||||||
AND ocr.id_cart_rule = '.(int)$id_cart_rule);
|
SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
|
||||||
|
LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
|
||||||
|
WHERE o.id_customer = '.(int)$id_customer.'
|
||||||
|
AND ocr.id_cart_rule = '.(int)$id_cart_rule);
|
||||||
|
Cache::store($cache_id, $result);
|
||||||
|
}
|
||||||
|
return Cache::retrieve($cache_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user