[-] Core: Product::getPriceStatic called with 1 quantity return the specific price for 1 qty if called with id_cart = 0
This commit is contained in:
+24
-13
@@ -94,7 +94,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
if (parent::add($autodate, $nullValues))
|
if (parent::add($autodate, $nullValues))
|
||||||
{
|
{
|
||||||
// Flush cache when we adding a new specific price
|
// Flush cache when we adding a new specific price
|
||||||
self::$_specificPriceCache = array();
|
SpecificPrice::$_specificPriceCache = array();
|
||||||
Product::flushPriceCache();
|
Product::flushPriceCache();
|
||||||
// Set cache of feature detachable to true
|
// Set cache of feature detachable to true
|
||||||
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', '1');
|
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', '1');
|
||||||
@@ -108,7 +108,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
if (parent::update($null_values))
|
if (parent::update($null_values))
|
||||||
{
|
{
|
||||||
// Flush cache when we updating a new specific price
|
// Flush cache when we updating a new specific price
|
||||||
self::$_specificPriceCache = array();
|
SpecificPrice::$_specificPriceCache = array();
|
||||||
Product::flushPriceCache();
|
Product::flushPriceCache();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
if (parent::delete())
|
if (parent::delete())
|
||||||
{
|
{
|
||||||
// Flush cache when we deletind a new specific price
|
// Flush cache when we deletind a new specific price
|
||||||
self::$_specificPriceCache = array();
|
SpecificPrice::$_specificPriceCache = array();
|
||||||
Product::flushPriceCache();
|
Product::flushPriceCache();
|
||||||
// Refresh cache of feature detachable
|
// Refresh cache of feature detachable
|
||||||
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', SpecificPrice::isCurrentlyUsed($this->def['table']));
|
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', SpecificPrice::isCurrentlyUsed($this->def['table']));
|
||||||
@@ -180,9 +180,9 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
if (!SpecificPrice::isFeatureActive())
|
if (!SpecificPrice::isFeatureActive())
|
||||||
return explode(';', Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES'));
|
return explode(';', Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES'));
|
||||||
|
|
||||||
if (!isset(self::$_cache_priorities[(int)$id_product]))
|
if (!isset(SpecificPrice::$_cache_priorities[(int)$id_product]))
|
||||||
{
|
{
|
||||||
self::$_cache_priorities[(int)$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
SpecificPrice::$_cache_priorities[(int)$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT `priority`, `id_specific_price_priority`
|
SELECT `priority`, `id_specific_price_priority`
|
||||||
FROM `'._DB_PREFIX_.'specific_price_priority`
|
FROM `'._DB_PREFIX_.'specific_price_priority`
|
||||||
WHERE `id_product` = '.(int)$id_product.'
|
WHERE `id_product` = '.(int)$id_product.'
|
||||||
@@ -190,7 +190,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
$priority = self::$_cache_priorities[(int)$id_product];
|
$priority = SpecificPrice::$_cache_priorities[(int)$id_product];
|
||||||
|
|
||||||
if (!$priority)
|
if (!$priority)
|
||||||
$priority = Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES');
|
$priority = Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES');
|
||||||
@@ -209,11 +209,11 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity);
|
$key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity);
|
||||||
if (!array_key_exists($key, self::$_specificPriceCache))
|
if (!array_key_exists($key, SpecificPrice::$_specificPriceCache))
|
||||||
{
|
{
|
||||||
$now = date('Y-m-d H:i:s');
|
$now = date('Y-m-d H:i:s');
|
||||||
self::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
$query = '
|
||||||
SELECT *, '.SpecificPrice::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer).'
|
SELECT *, '.SpecificPrice::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer).'
|
||||||
FROM `'._DB_PREFIX_.'specific_price`
|
FROM `'._DB_PREFIX_.'specific_price`
|
||||||
WHERE `id_product` IN (0, '.(int)$id_product.')
|
WHERE `id_product` IN (0, '.(int)$id_product.')
|
||||||
AND `id_product_attribute` IN (0, '.(int)$id_product_attribute.')
|
AND `id_product_attribute` IN (0, '.(int)$id_product_attribute.')
|
||||||
@@ -228,11 +228,22 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
AND
|
AND
|
||||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||||
)
|
)
|
||||||
AND id_cart IN (0, '.(int)$id_cart.')'.
|
AND id_cart IN (0, '.(int)$id_cart.') ';
|
||||||
(($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION')) ? ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')' : 'AND `from_quantity` <= '.max(1, (int)$real_quantity)).'
|
|
||||||
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
if ($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION'))
|
||||||
|
$query .= ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qty_to_use = $id_cart ? (int)$quantity : (int)$real_quantity;
|
||||||
|
$query .= 'AND `from_quantity` <= '.max(1, $qty_to_use);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC';
|
||||||
|
|
||||||
|
SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||||
|
|
||||||
}
|
}
|
||||||
return self::$_specificPriceCache[$key];
|
return SpecificPrice::$_specificPriceCache[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setPriorities($priorities)
|
public static function setPriorities($priorities)
|
||||||
|
|||||||
Reference in New Issue
Block a user