// 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.
+11 -3
View File
@@ -144,15 +144,21 @@ class AdminProductsControllerCore extends AdminController
$alias = 'sa';
$alias_image = 'image_shop';
if (Shop::getContext() == Shop::CONTEXT_SHOP)
{
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop='.(int)$this->context->shop->id.')';
$this->_where .= 'AND (i.id_image IS NULL OR image_shop.id_shop='.(int)$this->context->shop->id.')';
}
else
{
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop=a.id_shop_default)';
$this->_where .= 'AND (i.id_image IS NULL OR image_shop.id_shop=a.id_shop_default)';
}
$this->_select .= 'shop.name as shopname, ';
}
else
@@ -168,9 +174,6 @@ class AdminProductsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').') ';
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', '.$alias_image.'.`id_image`, '.$alias.'.`price`, ('.$alias.'.`price` * ((100 + (t.`rate`))/100)) AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
if (Shop::isFeatureActive())
$this->_where .= ' AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
$this->fields_list = array();
$this->fields_list['id_product'] = array(
@@ -3413,6 +3416,11 @@ class AdminProductsControllerCore extends AdminController
$shops = false;
if (Shop::isFeatureActive())
$shops = Shop::getShops();
foreach ($shops as $key => $shop)
if (!$obj->isAssociatedToShop($shop['id_shop']))
unset($shops[$key]);
$data->assign('shops', $shops);
$count_images = Db::getInstance()->getValue('