Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/css/modules.css admin-dev/themes/default/template/controllers/carts/helpers/view/view.tpl admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl admin-dev/themes/default/template/controllers/products/images.tpl admin-dev/themes/default/template/controllers/products/prices.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl classes/Autoload.php classes/Carrier.php classes/Product.php classes/ProductSale.php classes/Tools.php classes/Validate.php classes/tax/TaxRulesTaxManager.php controllers/admin/AdminPPreferencesController.php controllers/admin/AdminPerformanceController.php install-dev/install_version.php js/admin_carrier_wizard.js modules/blockcategories/blockcategories.php modules/blocklayered/blocklayered.php modules/statsequipment/statsequipment.php modules/statsproduct/statsproduct.php modules/watermark/watermark.php themes/default/address.tpl themes/default/authentication.tpl themes/default/category.tpl themes/default/contact-form.tpl themes/default/css/history.css themes/default/header.tpl themes/default/js/cart-summary.js themes/default/js/product.js themes/default/mobile/order-detail.tpl themes/default/modules/blocksearch/blocksearch.tpl themes/default/modules/productcomments/productcomments.tpl themes/default/order-carrier.tpl themes/default/order-detail.tpl themes/default/order-opc-new-account.tpl themes/default/product.tpl
This commit is contained in:
@@ -53,6 +53,8 @@ class StockAvailableCore extends ObjectModel
|
||||
/** @var bool determine if a product is out of stock - it was previously in Product class */
|
||||
public $out_of_stock = false;
|
||||
|
||||
protected static $cache_quantity_available;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
@@ -343,18 +345,23 @@ class StockAvailableCore extends ObjectModel
|
||||
if ($id_product_attribute === null)
|
||||
$id_product_attribute = 0;
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(quantity)');
|
||||
$query->from('stock_available');
|
||||
$key = (int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_shop;
|
||||
if (!isset(self::$cache_quantity_available[$key]))
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(quantity)');
|
||||
$query->from('stock_available');
|
||||
|
||||
// if null, it's a product without attributes
|
||||
if ($id_product !== null)
|
||||
$query->where('id_product = '.(int)$id_product);
|
||||
|
||||
$query->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$query = StockAvailable::addSqlShopRestriction($query, $id_shop);
|
||||
|
||||
// if null, it's a product without attributes
|
||||
if ($id_product !== null)
|
||||
$query->where('id_product = '.(int)$id_product);
|
||||
|
||||
$query->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$query = StockAvailable::addSqlShopRestriction($query, $id_shop);
|
||||
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
self::$cache_quantity_available[$key] = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
}
|
||||
return self::$cache_quantity_available[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user