// Fix #PSCFV-4628

This commit is contained in:
rGaillard
2012-10-02 18:57:39 +00:00
parent 8fa71daa6a
commit 7ee95c63f6
5 changed files with 40 additions and 9 deletions
+7 -3
View File
@@ -89,9 +89,13 @@ class ImageCore extends ObjectModel
public function delete()
{
if (!parent::delete() ||
!$this->deleteProductAttributeImage() ||
!$this->deleteImage())
if (!parent::delete())
return false;
if ($this->hasMultishopEntries())
return true;
if (!$this->deleteProductAttributeImage() || !$this->deleteImage())
return false;
// update positions
+1 -2
View File
@@ -660,11 +660,10 @@ class ProductCore extends ObjectModel
if ($real_quantity > $physical_quantity)
return false;
}
$result = parent::delete();
// Removes the product from StockAvailable, for the current shop
StockAvailable::removeProductFromStockAvailable($this->id);
$result = parent::delete();
$result &= ($this->deleteProductAttributes() && $this->deleteImages() && $this->deleteSceneProducts());
// If there are still entries in product_shop, don't remove completly the product
if ($this->hasMultishopEntries())
+1 -1
View File
@@ -749,7 +749,7 @@ class ShopCore extends ObjectModel
*/
public static function getSharedShops($shop_id, $type)
{
if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER)))
if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER, SHOP::SHARE_STOCK)))
die('Wrong argument ($type) in Shop::getSharedShops() method');
Shop::cacheShops();
+20
View File
@@ -521,6 +521,26 @@ class StockAvailableCore extends ObjectModel
{
if (!Validate::isUnsignedId($id_product))
return false;
if (Shop::getContext() == SHOP::CONTEXT_SHOP)
if (Shop::getContextShopGroup()->share_stock == 1)
{
$pa_sql = '';
if ($id_product_attribute !== null)
{
$pa_sql = '_attribute';
$id_product_attribute_sql = $id_product_attribute;
}
else
$id_product_attribute_sql = $id_product;
if ((int)Db::getInstance()->getValue('SELECT COUNT(*)
FROM '._DB_PREFIX_.'product'.$pa_sql.'_shop
WHERE id_product'.$pa_sql.'='.(int)$id_product_attribute_sql.'
AND id_shop IN ('.implode(',', array_map('intval', Shop::getContextListShopID(SHOP::SHARE_STOCK))).')'))
return true;
}
return Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'stock_available
WHERE id_product = '.(int)$id_product.