// When removing a product, its stock available is now properly removed
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10111 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -601,6 +601,14 @@ class ProductCore extends ObjectModel
|
|||||||
if ($real_quantity > $physical_quantity)
|
if ($real_quantity > $physical_quantity)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.5.0
|
||||||
|
* Removes the product from StockAvailable, for the current shop
|
||||||
|
*/
|
||||||
|
$context = Context::getContext();
|
||||||
|
$id_shop = $context->shop->id;
|
||||||
|
StockAvailable::removeProductFromStockAvailable($this->id, null, $id_shop);
|
||||||
|
|
||||||
if (!GroupReduction::deleteProductReduction($this->id))
|
if (!GroupReduction::deleteProductReduction($this->id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -291,4 +291,20 @@ class StockAvailableCore extends ObjectModel
|
|||||||
$stock_available->quantity = $stock_available->quantity + $delta_quantity;
|
$stock_available->quantity = $stock_available->quantity + $delta_quantity;
|
||||||
$stock_available->save();
|
$stock_available->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a given product from the stock available
|
||||||
|
*
|
||||||
|
* @param int $id_product
|
||||||
|
* @param int $id_product_attribute Optional
|
||||||
|
* @param int $id_shop Optional
|
||||||
|
*/
|
||||||
|
public static function removeProductFromStockAvailable($id_product, $id_product_attribute = null, $id_shop = null)
|
||||||
|
{
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
DELETE FROM '._DB_PREFIX_.'stock_available
|
||||||
|
WHERE id_product = '.(int)$id_product.
|
||||||
|
($id_product_attribute ? ' AND id_product_attribute = '.(int)$id_product_attribute : '').
|
||||||
|
($id_shop ? ' AND id_shop = '.(int)$id_shop : ''));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user