From e8718ec42f393ab48fbf9c6da6fe699a9ecb4f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 11 Dec 2012 12:01:04 +0100 Subject: [PATCH] [-] BO: Fix root category should anyway be imported in shop creation #PSCFV-5885 --- .../controllers/shop/helpers/form/form.tpl | 14 ++++++++++---- classes/shop/Shop.php | 6 +++++- controllers/admin/AdminShopController.php | 7 ++++--- 3 files changed, 19 insertions(+), 8 deletions(-) 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 bfba5f161..1f812981f 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 @@ -119,10 +119,16 @@ {/foreach} $(document).ready(function() { $('input[name=useImportData]').click(function() { - if ($(this).attr('id') == 'useImportData_on') - $('#shop_list, #data_list').slideDown('slow'); - else - $('#shop_list, #data_list').slideUp('slow'); + if ($(this).attr('id') == 'useImportData_on') + { + $('input[name^="importData["]').prop('checked', true); + $('#shop_list, #data_list').slideDown('slow'); + } + else + { + $('input[name^="importData["]').prop('checked', false); + $('#shop_list, #data_list').slideUp('slow'); + } }); $('#id_category, #importFromShop').change(function(){ shop_id = $('#importFromShop').val(); diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index d0a426706..5af053409 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -179,7 +179,7 @@ class ShopCore extends ObjectModel 'supplier' => array('type' => 'shop'), ); - foreach($asso_tables as $table_name => $table_details) + foreach ($asso_tables as $table_name => $table_details) Shop::addTableAssociation($table_name, $table_details); Shop::$initialized = true; @@ -975,6 +975,10 @@ class ShopCore extends ObjectModel { // If we duplicate some specific data, automatically duplicate other data linked to the first // E.g. if carriers are duplicated for the shop, duplicate carriers langs too + + if (!$old_id) + $old_id = Configuration::get('PS_SHOP_DEFAULT'); + if (isset($tables_import['carrier'])) { $tables_import['carrier_tax_rules_group_shop'] = true; diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php index 71bab9f66..43455ab02 100755 --- a/controllers/admin/AdminShopController.php +++ b/controllers/admin/AdminShopController.php @@ -265,9 +265,10 @@ class AdminShopControllerCore extends AdminController protected function afterAdd($new_shop) { - $import_data = Tools::getValue('importData'); - if (Tools::getValue('useImportData') && is_array($import_data)) - $new_shop->copyShopData((int)Tools::getValue('importFromShop'), $import_data); + $import_data = Tools::getValue('importData', array()); + + // The root category should be at least imported + $new_shop->copyShopData((int)Tools::getValue('importFromShop'), $import_data); // copy default data if (!Tools::getValue('useImportData') || (is_array($import_data) && !isset($import_data['group'])))