[-] BO : Fix bug #PSCFV-8389 duplicates is SpecificPrice table
This commit is contained in:
1 parent
da48cea96e
commit
e9a3c98af9
2 files changed
+41
-20
No files matched your search
@@ -229,7 +229,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||||
)
|
)
|
||||||
AND id_cart IN (0, '.(int)$id_cart.')'.
|
AND id_cart IN (0, '.(int)$id_cart.')'.
|
||||||
(($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION')) ? ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')' : 'AND `from_quantity` <= '.(int)$real_quantity).'
|
(($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION')) ? ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')' : 'AND `from_quantity` <= '.max(1, (int)$real_quantity)).'
|
||||||
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
||||||
}
|
}
|
||||||
return self::$_specificPriceCache[$key];
|
return self::$_specificPriceCache[$key];
|
||||||
|
|||||||
@@ -1395,25 +1395,46 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SpecificPrice (only the basic reduction feature is supported by the import)
|
// SpecificPrice (only the basic reduction feature is supported by the import)
|
||||||
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
if (!Shop::isFeatureActive())
|
||||||
{
|
$info['shop'] = 1;
|
||||||
$specific_price = new SpecificPrice();
|
elseif (!isset($info['shop']) || empty($info['shop']))
|
||||||
$specific_price->id_product = (int)$product->id;
|
$info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
|
||||||
// @todo multishop specific price import
|
|
||||||
$specific_price->id_shop = $this->context->shop->id;
|
// Get shops for each attributes
|
||||||
$specific_price->id_currency = 0;
|
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
|
||||||
$specific_price->id_country = 0;
|
|
||||||
$specific_price->id_group = 0;
|
$id_shop_list = array();
|
||||||
$specific_price->price = -1;
|
foreach ($info['shop'] as $shop)
|
||||||
$specific_price->id_customer = 0;
|
if (!is_numeric($shop))
|
||||||
$specific_price->from_quantity = 1;
|
$id_shop_list[] = (int)Shop::getIdByName($shop);
|
||||||
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
else
|
||||||
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
$id_shop_list[] = $shop;
|
||||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
|
||||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
||||||
if (!$specific_price->add())
|
foreach($id_shop_list as $id_shop)
|
||||||
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
{
|
||||||
}
|
$specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (is_array($specific_price))
|
||||||
|
$specific_price = new SpecificPrice((int)$specific_price['id_specific_price']);
|
||||||
|
else
|
||||||
|
$specific_price = new SpecificPrice();
|
||||||
|
$specific_price->id_product = (int)$product->id;
|
||||||
|
$specific_price->id_specific_price_rule = 0;
|
||||||
|
$specific_price->id_shop = $id_shop;
|
||||||
|
$specific_price->id_currency = 0;
|
||||||
|
$specific_price->id_country = 0;
|
||||||
|
$specific_price->id_group = 0;
|
||||||
|
$specific_price->price = -1;
|
||||||
|
$specific_price->id_customer = 0;
|
||||||
|
$specific_price->from_quantity = 1;
|
||||||
|
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
||||||
|
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
||||||
|
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||||
|
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||||
|
if (!$specific_price->save())
|
||||||
|
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($product->tags) && !empty($product->tags))
|
if (isset($product->tags) && !empty($product->tags))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user