[-] BO: Fix bugs with stock management
This commit is contained in:
1 parent
4faf469eb1
commit
836aac77de
3 files changed
+15
-8
No files matched your search
@@ -4810,6 +4810,11 @@ class ProductCore extends ObjectModel
|
|||||||
$this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
|
$this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
|
||||||
$this->out_of_stock = StockAvailable::outOfStock($this->id);
|
$this->out_of_stock = StockAvailable::outOfStock($this->id);
|
||||||
$this->depends_on_stock = StockAvailable::dependsOnStock($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)
|
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)
|
if ($existing_id > 0)
|
||||||
{
|
{
|
||||||
Db::getInstance()->update('stock_available', array(
|
Db::getInstance()->update('stock_available', array(
|
||||||
@@ -638,10 +635,15 @@ class StockAvailableCore extends ObjectModel
|
|||||||
|
|
||||||
// if there is no $id_shop, gets the context one
|
// if there is no $id_shop, gets the context one
|
||||||
// get shop group too
|
// get shop group too
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
{
|
{
|
||||||
$id_shop = $context->shop->id;
|
if (Shop::getContext() == Shop::CONTEXT_GROUP)
|
||||||
$shop_group = $context->shop->getGroup();
|
$shop_group = Shop::getContextShopGroup();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$shop_group = $context->shop->getGroup();
|
||||||
|
$id_shop = $context->shop->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3799,7 +3799,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
if (!Tools::getValue('actionQty'))
|
if (!Tools::getValue('actionQty'))
|
||||||
return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
|
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'))
|
switch (Tools::getValue('actionQty'))
|
||||||
{
|
{
|
||||||
case 'depends_on_stock':
|
case 'depends_on_stock':
|
||||||
|
|||||||
Reference in new issue
Block a user