[-] Core: Fix PSCFV-2984 specific price rules are deleted on all products when you edit one
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16434 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -119,15 +119,18 @@ class SpecificPriceRuleCore extends ObjectModel
|
|||||||
|
|
||||||
public function apply($products = false)
|
public function apply($products = false)
|
||||||
{
|
{
|
||||||
$this->resetApplication();
|
$this->resetApplication($products);
|
||||||
$products = $this->getAffectedProducts($products);
|
$products = $this->getAffectedProducts($products);
|
||||||
foreach ($products as $product)
|
foreach ($products as $product)
|
||||||
SpecificPriceRule::applyRuleToProduct((int)$this->id, (int)$product['id_product'], (int)$product['id_product_attribute']);
|
SpecificPriceRule::applyRuleToProduct((int)$this->id, (int)$product['id_product'], (int)$product['id_product_attribute']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetApplication()
|
public function resetApplication($products = false)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_specific_price_rule='.(int)$this->id);
|
$where = '';
|
||||||
|
if ($products && count($products))
|
||||||
|
$where .= ' AND id_product IN ('.implode(', ', array_map('intval', $products)).')';
|
||||||
|
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_specific_price_rule='.(int)$this->id.$where);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function applyAllRules($products = false)
|
public static function applyAllRules($products = false)
|
||||||
@@ -178,6 +181,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
|||||||
$attributes = false;
|
$attributes = false;
|
||||||
$categories = false;
|
$categories = false;
|
||||||
$features = false;
|
$features = false;
|
||||||
|
$suppliers = false;
|
||||||
$where = false;
|
$where = false;
|
||||||
|
|
||||||
if ($conditions_group)
|
if ($conditions_group)
|
||||||
@@ -195,7 +199,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
|||||||
'values' => array(),
|
'values' => array(),
|
||||||
),
|
),
|
||||||
'supplier' => array(
|
'supplier' => array(
|
||||||
'name' => 'p.id_supplier',
|
'name' => 'pss.id_supplier',
|
||||||
'values' => array()
|
'values' => array()
|
||||||
),
|
),
|
||||||
'feature' => array(
|
'feature' => array(
|
||||||
@@ -216,6 +220,8 @@ class SpecificPriceRuleCore extends ObjectModel
|
|||||||
$features = true;
|
$features = true;
|
||||||
elseif ($condition['type'] == 'attribute')
|
elseif ($condition['type'] == 'attribute')
|
||||||
$attributes = true;
|
$attributes = true;
|
||||||
|
elseif ($condition['type'] == 'supplier')
|
||||||
|
$suppliers = true;
|
||||||
|
|
||||||
$fields[$condition['type']]['values'][] = $condition['value'];
|
$fields[$condition['type']]['values'][] = $condition['value'];
|
||||||
}
|
}
|
||||||
@@ -249,9 +255,13 @@ class SpecificPriceRuleCore extends ObjectModel
|
|||||||
$query->select('NULL as id_product_attribute');
|
$query->select('NULL as id_product_attribute');
|
||||||
|
|
||||||
if ($features)
|
if ($features)
|
||||||
$query->leftJoin('feature_product', 'fp', 'p.id_product = fp.id_product');
|
$query->leftJoin('feature_product', 'fp', 'p.id_product = fp.id_product');
|
||||||
if ($categories)
|
if ($categories)
|
||||||
$query->leftJoin('category_product', 'cp', 'p.id_product = cp.id_product');
|
$query->leftJoin('category_product', 'cp', 'p.id_product = cp.id_product');
|
||||||
|
|
||||||
|
if ($suppliers)
|
||||||
|
$query->leftJoin('product_supplier', 'pss', 'p.id_product = pss.id_product');
|
||||||
|
|
||||||
if ($where)
|
if ($where)
|
||||||
$query->where($where);
|
$query->where($where);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user