// Manage SQL upgrade for stock management + bug fix
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
function set_product_suppliers()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||
SELECT id_supplier, id_product, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `id_supplier` > 0
|
||||
@@ -19,7 +19,7 @@ function set_product_suppliers()
|
||||
');
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
$attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT id_product_attribute, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
@@ -28,9 +28,6 @@ function set_product_suppliers()
|
||||
//Add each attribute to stock_available
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
// add to global quantity
|
||||
$quantity += $attribute['quantity'];
|
||||
|
||||
// set supplier for attribute
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_supplier`
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
function set_stock_available()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||
SELECT quantity, id_product, out_of_stock
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `active` = 1
|
||||
@@ -13,7 +13,7 @@ function set_stock_available()
|
||||
$quantity = 0;
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
$attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT quantity, id_product_attribute
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
|
||||
@@ -4,7 +4,7 @@ function update_stock_mvt_reason()
|
||||
{
|
||||
//Get all stock mvts reasons already presents in the solution (from 1.4.x)
|
||||
//Remove standard movements to keep only custom movement
|
||||
$mvts = Db::getInstance()->ExecuteS('
|
||||
$mvts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT smr.*
|
||||
FROM `'._DB_PREFIX_.'stock_mvt_reason`
|
||||
WHERE `id` > 5
|
||||
@@ -12,7 +12,7 @@ function update_stock_mvt_reason()
|
||||
|
||||
//Get all stock mvts reasons language traduction already presents in the solution (from 1.4.x)
|
||||
//Remove standard movements to keep only custom movement
|
||||
$mvts_lang = Db::getInstance()->ExecuteS('
|
||||
$mvts_lang = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT smrl.*
|
||||
FROM `'._DB_PREFIX_.'stock_movement_reason_lang`
|
||||
WHERE `id_stock_mvt_reason` > 5
|
||||
|
||||
Reference in New Issue
Block a user