// Fix product multishop association when the product is created before the shop

This commit is contained in:
Rémi Gaillard
2013-03-15 15:23:18 +01:00
parent e015d9d25e
commit 74533ab801
@@ -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;
}