[-] BO: Fix bugs with stock management
This commit is contained in:
@@ -4810,6 +4810,11 @@ class ProductCore extends ObjectModel
|
||||
$this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
|
||||
$this->out_of_stock = StockAvailable::outOfStock($this->id);
|
||||
$this->depends_on_stock = StockAvailable::dependsOnStock($this->id);
|
||||
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1)
|
||||
|
||||
$this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management`
|
||||
FROM '._DB_PREFIX_.'product_shop
|
||||
WHERE id_product='.(int)$this->id.Shop::addSqlRestriction());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -217,11 +217,8 @@ class StockAvailableCore extends ObjectModel
|
||||
*/
|
||||
public static function setProductDependsOnStock($id_product, $depends_on_stock = true, $id_shop = null, $id_product_attribute = 0)
|
||||
{
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, (int)$id_shop);
|
||||
|
||||
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, $id_shop);
|
||||
if ($existing_id > 0)
|
||||
{
|
||||
Db::getInstance()->update('stock_available', array(
|
||||
@@ -638,10 +635,15 @@ class StockAvailableCore extends ObjectModel
|
||||
|
||||
// if there is no $id_shop, gets the context one
|
||||
// get shop group too
|
||||
if ($id_shop === null)
|
||||
if ($id_shop === null)
|
||||
{
|
||||
$id_shop = $context->shop->id;
|
||||
$shop_group = $context->shop->getGroup();
|
||||
if (Shop::getContext() == Shop::CONTEXT_GROUP)
|
||||
$shop_group = Shop::getContextShopGroup();
|
||||
else
|
||||
{
|
||||
$shop_group = $context->shop->getGroup();
|
||||
$id_shop = $context->shop->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3799,7 +3799,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!Tools::getValue('actionQty'))
|
||||
return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
|
||||
|
||||
$product = new Product((int)Tools::getValue('id_product'));
|
||||
$product = new Product((int)Tools::getValue('id_product'), true);
|
||||
switch (Tools::getValue('actionQty'))
|
||||
{
|
||||
case 'depends_on_stock':
|
||||
|
||||
Reference in New Issue
Block a user