// Fix product multishop association when the product is created before the shop
This commit is contained in:
@@ -356,7 +356,16 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
$result = parent::loadObject($opt);
|
||||
if ($result && Validate::isLoadedObject($this->object))
|
||||
{
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && !$this->object->isAssociatedToShop())
|
||||
{
|
||||
$default_product = new Product((int)$this->object->id, false, null, (int)$this->object->id_shop_default);
|
||||
$def = ObjectModel::getDefinition($this->object);
|
||||
foreach ($def['fields'] as $field_name => $row)
|
||||
$this->object->$field_name = $default_product->$field_name;
|
||||
}
|
||||
$this->object->loadStockData();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user