From 160943868ab282db45bd208335195708febc019d Mon Sep 17 00:00:00 2001 From: vChabot Date: Mon, 6 Aug 2012 14:09:44 +0000 Subject: [PATCH] [-] BO : BugFix : #PSCFV-3537 : Product Indexing lost when editing a product --- .../controllers/shop/helpers/form/form.tpl | 20 +++++++++++++++++++ controllers/admin/AdminShopController.php | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/admin-dev/themes/default/template/controllers/shop/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/shop/helpers/form/form.tpl index b45b3d71f..cb43c89d0 100644 --- a/admin-dev/themes/default/template/controllers/shop/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/shop/helpers/form/form.tpl @@ -114,6 +114,10 @@ {/block} {block name="script"} + var ids_category = new Array(); + {foreach $ids_category as $key => $id_category} + ids_category[{$key}] = {$id_category}; + {/foreach} $(document).ready(function() { $('input[name=useImportData]').click(function() { if ($(this).attr('id') == 'useImportData_on') @@ -121,5 +125,21 @@ else $('#shop_list, #data_list').slideUp('slow'); }); + $('#id_category, #importFromShop').change(function(){ + shop_id = $('#importFromShop').val(); + category_id = $('#id_category').val(); + if (ids_category[shop_id] != category_id) + disableProductsDuplication(); + else + enableProductsDuplication(); + }); }); + function disableProductsDuplication() + { + $('input[name="importData[product_attribute]"], input[name="importData[image]"], input[name="importData[product]"], input[name="importData[stock_available]"], input[name="importData[discount]"]').removeAttr('checked').attr('disabled', 'disabled'); + } + function enableProductsDuplication() + { + $('input[name="importData[product_attribute]"], input[name="importData[image]"], input[name="importData[product]"], input[name="importData[stock_available]"], input[name="importData[discount]"]').removeAttr('disabled').attr('checked', 'checked'); + } {/block} diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php index c76502dcd..830cf1617 100755 --- a/controllers/admin/AdminShopController.php +++ b/controllers/admin/AdminShopController.php @@ -521,10 +521,16 @@ class AdminShopControllerCore extends AdminController 'id_theme_checked' => (isset($obj->id_theme) ? $obj->id_theme : $id_theme) ); + $ids_category = array(); + $shops = Shop::getShops(false); + foreach ($shops as $shop) + $ids_category[$shop['id_shop']] = $shop['id_category']; + $this->tpl_form_vars = array( 'disabled' => $disabled, 'checked' => (Tools::getValue('addshop') !== false) ? true : false, 'defaultShop' => (int)Configuration::get('PS_SHOP_DEFAULT'), + 'ids_category' => $ids_category, ); if (isset($this->fields_import_form)) $this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form));