[-] BO: Fix of product combinations edition and duplication of combination per shop
This commit is contained in:
1 parent
4746660bad
commit
9a438dec72
2 files changed
+31
-27
No files matched your search
+11
-3
@@ -987,7 +987,7 @@ class ProductCore extends ObjectModel
|
|||||||
return count($result) > 0;
|
return count($result) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function productAttributeExists($attributes_list, $current_product_attribute = false, Context $context = null)
|
public function productAttributeExists($attributes_list, $current_product_attribute = false, Context $context = null, $all_shops = false, $return_id = false)
|
||||||
{
|
{
|
||||||
if (!Combination::isFeatureActive())
|
if (!Combination::isFeatureActive())
|
||||||
return false;
|
return false;
|
||||||
@@ -998,7 +998,7 @@ class ProductCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||||
JOIN `'._DB_PREFIX_.'product_attribute_shop` pas ON (pas.id_product_attribute = pa.id_product_attribute)
|
JOIN `'._DB_PREFIX_.'product_attribute_shop` pas ON (pas.id_product_attribute = pa.id_product_attribute)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||||
WHERE pas.id_shop ='.(int)$context->shop->id.' AND pa.`id_product` = '.(int)$this->id
|
WHERE 1 '.(!$all_shops ? ' AND pas.id_shop ='.(int)$context->shop->id : '').' AND pa.`id_product` = '.(int)$this->id
|
||||||
);
|
);
|
||||||
|
|
||||||
/* If something's wrong */
|
/* If something's wrong */
|
||||||
@@ -1017,9 +1017,17 @@ class ProductCore extends ObjectModel
|
|||||||
$diff = false;
|
$diff = false;
|
||||||
for ($i = 0; $diff == false && isset($product_attribute[$i]); $i++)
|
for ($i = 0; $diff == false && isset($product_attribute[$i]); $i++)
|
||||||
if (!in_array($product_attribute[$i], $attributes_list) || $key == $current_product_attribute)
|
if (!in_array($product_attribute[$i], $attributes_list) || $key == $current_product_attribute)
|
||||||
$diff = true;
|
{
|
||||||
|
if ($return_id)
|
||||||
|
return $key;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!$diff)
|
if (!$diff)
|
||||||
|
{
|
||||||
|
if ($return_id)
|
||||||
|
return $key;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -668,35 +668,31 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
if (Tools::getValue('attribute_default'))
|
if (Tools::getValue('attribute_default'))
|
||||||
$product->deleteDefaultAttributes();
|
$product->deleteDefaultAttributes();
|
||||||
// Change existing one
|
// Change existing one
|
||||||
if ($id_product_attribute = (int)Tools::getValue('id_product_attribute'))
|
if (($id_product_attribute = (int)Tools::getValue('id_product_attribute')) || ($id_product_attribute = $product->productAttributeExists(Tools::getValue('attribute_combination_list'), false, null, true, true)))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
if ($this->tabAccess['edit'] === '1')
|
||||||
{
|
{
|
||||||
if ($product->productAttributeExists(Tools::getValue('attribute_combination_list'), (int)$id_product_attribute))
|
|
||||||
$this->errors[] = Tools::displayError('This attribute already exists.');
|
if ($this->isProductFieldUpdated('available_date_attribute') && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))
|
||||||
|
$this->errors[] = Tools::displayError('Invalid date format.');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->isProductFieldUpdated('available_date_attribute') && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))
|
$product->updateAttribute((int)$id_product_attribute,
|
||||||
$this->errors[] = Tools::displayError('Invalid date format.');
|
$this->isProductFieldUpdated('attribute_wholesale_price') ? Tools::getValue('attribute_wholesale_price') : null,
|
||||||
else
|
$this->isProductFieldUpdated('attribute_price_impact') ? Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact') : null,
|
||||||
{
|
$this->isProductFieldUpdated('attribute_weight_impact') ? Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact') : null,
|
||||||
$product->updateAttribute((int)$id_product_attribute,
|
$this->isProductFieldUpdated('attribute_unit_impact') ? Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact') : null,
|
||||||
$this->isProductFieldUpdated('attribute_wholesale_price') ? Tools::getValue('attribute_wholesale_price') : null,
|
$this->isProductFieldUpdated('attribute_ecotax') ? Tools::getValue('attribute_ecotax') : null,
|
||||||
$this->isProductFieldUpdated('attribute_price_impact') ? Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact') : null,
|
Tools::getValue('id_image_attr'),
|
||||||
$this->isProductFieldUpdated('attribute_weight_impact') ? Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact') : null,
|
Tools::getValue('attribute_reference'),
|
||||||
$this->isProductFieldUpdated('attribute_unit_impact') ? Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact') : null,
|
Tools::getValue('attribute_ean13'),
|
||||||
$this->isProductFieldUpdated('attribute_ecotax') ? Tools::getValue('attribute_ecotax') : null,
|
$this->isProductFieldUpdated('attribute_default') ? Tools::getValue('attribute_default') : null,
|
||||||
Tools::getValue('id_image_attr'),
|
Tools::getValue('attribute_location'),
|
||||||
Tools::getValue('attribute_reference'),
|
Tools::getValue('attribute_upc'),
|
||||||
Tools::getValue('attribute_ean13'),
|
$this->isProductFieldUpdated('attribute_minimal_quantity') ? Tools::getValue('attribute_minimal_quantity') : null,
|
||||||
$this->isProductFieldUpdated('attribute_default') ? Tools::getValue('attribute_default') : null,
|
$this->isProductFieldUpdated('available_date_attribute') ? Tools::getValue('available_date_attribute') : null,
|
||||||
Tools::getValue('attribute_location'),
|
false);
|
||||||
Tools::getValue('attribute_upc'),
|
}
|
||||||
$this->isProductFieldUpdated('attribute_minimal_quantity') ? Tools::getValue('attribute_minimal_quantity') : null,
|
|
||||||
$this->isProductFieldUpdated('available_date_attribute') ? Tools::getValue('available_date_attribute') : null,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to add here.');
|
$this->errors[] = Tools::displayError('You do not have permission to add here.');
|
||||||
|
|||||||
Reference in new issue
Block a user