// you can now associate a product to a shop which created on another shop

This commit is contained in:
rGaillard committed 2012-08-29 15:00:38 +00:00
1 parent ec9ea71f0e
commit 74f0995f1e
1 file changed
+63 -2
+63 -2
View File
@@ -2296,11 +2296,32 @@ class AdminProductsControllerCore extends AdminController
return; return;
$product = $this->object; $product = $this->object;
$this->product_exists_in_shop = true;
if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id))
{ {
$this->product_exists_in_shop = false;
if ($this->tab_display == 'Informations')
$this->displayWarning($this->l('Warning: this product does not exist in this shop.')); $this->displayWarning($this->l('Warning: this product does not exist in this shop.'));
return;
$default_product = new Product();
$fields_to_copy = array('minimal_quantity',
'price',
'additional_shipping_cost',
'wholesale_price',
'on_sale',
'online_only',
'unity',
'unit_price_ratio',
'ecotax',
'active',
'available_for_order',
'available_date',
'show_price',
'indexed',
'id_tax_rules_group',
'advanced_stock_management');
foreach ($fields_to_copy as $field)
$product->$field = $default_product->$field;
} }
// Product for multishop // Product for multishop
@@ -3177,6 +3198,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ((bool)$obj->id) if ((bool)$obj->id)
{
if ($this->product_exists_in_shop)
{ {
$labels = $obj->getCustomizationFields(); $labels = $obj->getCustomizationFields();
@@ -3195,6 +3218,9 @@ class AdminProductsControllerCore extends AdminController
'text_fields' => (int)($this->getFieldValue($obj, 'text_fields') ? (int)$this->getFieldValue($obj, 'text_fields') : '0'), 'text_fields' => (int)($this->getFieldValue($obj, 'text_fields') ? (int)$this->getFieldValue($obj, 'text_fields') : '0'),
)); ));
} }
else
$this->displayWarning($this->l('You must save this product in this shop before adding customization.'));
}
else else
$this->displayWarning($this->l('You must save this product before adding customization.')); $this->displayWarning($this->l('You must save this product before adding customization.'));
@@ -3206,6 +3232,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ((bool)$obj->id) if ((bool)$obj->id)
{
if ($this->product_exists_in_shop)
{ {
$attachment_name = array(); $attachment_name = array();
$attachment_description = array(); $attachment_description = array();
@@ -3232,6 +3260,9 @@ class AdminProductsControllerCore extends AdminController
'PS_ATTACHMENT_MAXIMUM_SIZE' => Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') 'PS_ATTACHMENT_MAXIMUM_SIZE' => Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE')
)); ));
} }
else
$this->displayWarning($this->l('You must save this product in this shop before adding attachements.'));
}
else else
$this->displayWarning($this->l('You must save this product before adding attachements.')); $this->displayWarning($this->l('You must save this product before adding attachements.'));
@@ -3372,6 +3403,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ((bool)$obj->id) if ((bool)$obj->id)
{
if ($this->product_exists_in_shop)
{ {
$data->assign('product', $this->loadObject()); $data->assign('product', $this->loadObject());
@@ -3403,6 +3436,9 @@ class AdminProductsControllerCore extends AdminController
$data->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute'))); $data->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute')));
$data->assign('currency', $this->context->currency); $data->assign('currency', $this->context->currency);
} }
else
$this->displayWarning($this->l('You must save this product in this shop before adding images.'));
}
else else
$this->displayWarning($this->l('You must save this product before adding images.')); $this->displayWarning($this->l('You must save this product before adding images.'));
@@ -3421,6 +3457,8 @@ class AdminProductsControllerCore extends AdminController
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:'). $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').
' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>'); ' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
else if (Validate::isLoadedObject($product)) else if (Validate::isLoadedObject($product))
{
if ($this->product_exists_in_shop)
{ {
if ($product->is_virtual) if ($product->is_virtual)
{ {
@@ -3472,6 +3510,9 @@ class AdminProductsControllerCore extends AdminController
)); ));
} }
} }
else
$this->displayWarning($this->l('You must save this product in this shop before adding combinations.'));
}
else else
{ {
$data->assign('product', $product); $data->assign('product', $product);
@@ -3584,6 +3625,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ($obj->id) if ($obj->id)
{
if ($this->product_exists_in_shop)
{ {
// Get all id_product_attribute // Get all id_product_attribute
$attributes = $obj->getAttributesResume($this->context->language->id); $attributes = $obj->getAttributesResume($this->context->language->id);
@@ -3709,6 +3752,9 @@ class AdminProductsControllerCore extends AdminController
'languages' => $this->_languages, 'languages' => $this->_languages,
)); ));
} }
else
$this->displayWarning($this->l('You must save this product in this shop before managing quantities.'));
}
else else
$this->displayWarning($this->l('You must save this product before managing quantities.')); $this->displayWarning($this->l('You must save this product before managing quantities.'));
@@ -3720,6 +3766,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ($obj->id) if ($obj->id)
{
if ($this->product_exists_in_shop)
{ {
// Get all id_product_attribute // Get all id_product_attribute
$attributes = $obj->getAttributesResume($this->context->language->id); $attributes = $obj->getAttributesResume($this->context->language->id);
@@ -3782,6 +3830,9 @@ class AdminProductsControllerCore extends AdminController
'id_default_currency' => Configuration::get('PS_CURRENCY_DEFAULT'), 'id_default_currency' => Configuration::get('PS_CURRENCY_DEFAULT'),
)); ));
} }
else
$this->displayWarning($this->l('You must save this product in this shop before managing suppliers'));
}
else else
$this->displayWarning($this->l('You must save this product before managing suppliers')); $this->displayWarning($this->l('You must save this product before managing suppliers'));
@@ -3793,6 +3844,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ($obj->id) if ($obj->id)
{
if ($this->product_exists_in_shop)
{ {
// Get all id_product_attribute // Get all id_product_attribute
$attributes = $obj->getAttributesResume($this->context->language->id); $attributes = $obj->getAttributesResume($this->context->language->id);
@@ -3827,6 +3880,9 @@ class AdminProductsControllerCore extends AdminController
'token' => $this->token 'token' => $this->token
)); ));
} }
else
$this->displayWarning($this->l('You must save this product in this shop before managing warehouses'));
}
else else
$this->displayWarning($this->l('You must save this product before managing warehouses')); $this->displayWarning($this->l('You must save this product before managing warehouses'));
@@ -3843,6 +3899,8 @@ class AdminProductsControllerCore extends AdminController
$data = $this->createTemplate($this->tpl_form); $data = $this->createTemplate($this->tpl_form);
if ($obj->id) if ($obj->id)
{
if ($this->product_exists_in_shop)
{ {
$features = Feature::getFeatures($this->context->language->id); $features = Feature::getFeatures($this->context->language->id);
@@ -3873,6 +3931,9 @@ class AdminProductsControllerCore extends AdminController
$data->assign('languages', $this->_languages); $data->assign('languages', $this->_languages);
$data->assign('default_form_language', $this->default_form_language); $data->assign('default_form_language', $this->default_form_language);
} }
else
$this->displayWarning($this->l('You must save this product in this shop before adding features.'));
}
else else
$this->displayWarning($this->l('You must save this product before adding features.')); $this->displayWarning($this->l('You must save this product before adding features.'));