// and again #PSCFV-1291, quantity was missing after upgrade, related to id_group_shop/id_shop_group modifications
This commit is contained in:
1 parent
f45dbae253
commit
3a7d189d8c
1 file changed
+10
-4
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
function set_stock_available()
|
function set_stock_available()
|
||||||
{
|
{
|
||||||
|
$res = true;
|
||||||
//Get all products with positive quantity
|
//Get all products with positive quantity
|
||||||
$resource = Db::getInstance()->query('
|
$resource = Db::getInstance()->query('
|
||||||
SELECT quantity, id_product, out_of_stock
|
SELECT quantity, id_product, out_of_stock
|
||||||
@@ -26,12 +27,14 @@ function set_stock_available()
|
|||||||
$quantity += $attribute['quantity'];
|
$quantity += $attribute['quantity'];
|
||||||
|
|
||||||
//add stock available for attributes
|
//add stock available for attributes
|
||||||
Db::getInstance()->execute('
|
$res &= Db::getInstance()->execute('
|
||||||
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
||||||
(`id_product`, `id_product_attribute`, `id_shop`, `id_shop_group`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
(`id_product`, `id_product_attribute`, `id_shop`, `id_group_shop`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
||||||
VALUES
|
VALUES
|
||||||
("'.(int)$row['id_product'].'", "'.(int)$attribute['id_product_attribute'].'", "1", "0", "'.(int)$attribute['quantity'].'", "0", "'.(int)$row['out_of_stock'].'")
|
("'.(int)$row['id_product'].'", "'.(int)$attribute['id_product_attribute'].'", "1", "0", "'.(int)$attribute['quantity'].'", "0", "'.(int)$row['out_of_stock'].'")
|
||||||
');
|
');
|
||||||
|
if (!$res)
|
||||||
|
return array('error' => Db::getInstance()->getNumberError(), 'msg' => '(attributes)'.Db::getInstance()->getMsgError());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($attributes) == 0)
|
if (count($attributes) == 0)
|
||||||
@@ -41,11 +44,14 @@ function set_stock_available()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Add stock available for product
|
//Add stock available for product
|
||||||
Db::getInstance()->execute('
|
$res &= Db::getInstance()->execute('
|
||||||
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
||||||
(`id_product`, `id_product_attribute`, `id_shop`, `id_shop_group`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
(`id_product`, `id_product_attribute`, `id_shop`, `id_group_shop`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
||||||
VALUES
|
VALUES
|
||||||
("'.(int)$row['id_product'].'", "0", "1", "0", "'.(int)$quantity.'", "0", "'.(int)$row['out_of_stock'].'")
|
("'.(int)$row['id_product'].'", "0", "1", "0", "'.(int)$quantity.'", "0", "'.(int)$row['out_of_stock'].'")
|
||||||
');
|
');
|
||||||
|
if (!$res)
|
||||||
|
return array('error' => Db::getInstance()->getNumberError(), 'msg' => '(products)'.Db::getInstance()->getMsgError());
|
||||||
}
|
}
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user