diff --git a/admin-dev/themes/default/template/controllers/products/associations.tpl b/admin-dev/themes/default/template/controllers/products/associations.tpl
index 70fb39855..14489e1c1 100644
--- a/admin-dev/themes/default/template/controllers/products/associations.tpl
+++ b/admin-dev/themes/default/template/controllers/products/associations.tpl
@@ -36,17 +36,12 @@
|
+ {include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
|
- {if !$is_shop_context}
-
- {/if}
{$category_tree}
- {if !$is_shop_context}
-
- {/if}
|
@@ -56,12 +51,10 @@
|
- {if $is_shop_context}
{l s='Create new category'}
- {/if}
|
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index b3fb6ac0c..636d698bb 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -2704,10 +2704,7 @@ class AdminProductsControllerCore extends AdminController
$tab_root = array('id_category' => $root->id, 'name' => $root->name);
$helper = new Helper();
- if (Shop::getContext() != Shop::CONTEXT_SHOP)
- $category_tree = $this->l('You must select a shop if you want to put your product into a particular shop.');
- else
- $category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true);
+ $category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true);
$data->assign(array('default_category' => $default_category,
'selected_cat_ids' => implode(',', array_keys($selected_cat)),
'selected_cat' => $selected_cat,
diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php
index 631132061..319bd63df 100755
--- a/controllers/admin/AdminShopController.php
+++ b/controllers/admin/AdminShopController.php
@@ -513,11 +513,13 @@ class AdminShopControllerCore extends AdminController
return $object;
}
- public function initCategoriesAssociation($id_root = 1)
+ public function initCategoriesAssociation($id_root = null)
{
+ if (is_null($id_root))
+ $id_root = Configuration::get('PS_ROOT_CATEGORY');
$id_shop = (int)Tools::getValue('id_shop');
$shop = new Shop($id_shop);
- $selected_cat = Shop::getCategories($id_shop);
+ $selected_cat = Shop::getCategories();
if (empty($selected_cat))
{
// get first category root and preselect all these children
diff --git a/js/admin-categories-tree.js b/js/admin-categories-tree.js
index 4bfc33413..2d9b6f394 100755
--- a/js/admin-categories-tree.js
+++ b/js/admin-categories-tree.js
@@ -35,15 +35,15 @@ var id_category_root = 0;
function buildTreeView()
{
- use_shop_context = false;
+ use_shop_context = 0;
if (buildTreeView.arguments[0])
- use_shop_context = true;
+ use_shop_context = 1;
$("#categories-treeview").treeview({
url : 'ajax.php',
toggle: function () { callbackToggle($(this)); },
ajax : {
type: 'POST',
- async: true,
+ async: false,
data: {
getChildrenCategories : true,
use_shop_context : use_shop_context,
@@ -57,7 +57,10 @@ function buildTreeView()
$('#categories-treeview li#'+id_category_root).
removeClass('collapsable lastCollapsable').
addClass('last static');
-
+
+ disabled = $('#categories-treeview li:first input[type=checkbox]').attr('disabled');
+ $('#categories-treeview input[type=checkbox]').attr('disabled', disabled);
+
$('#expand_all').click( function () {
expandAllCategories();
return false;
@@ -79,6 +82,12 @@ function buildTreeView()
uncheckAllCategories();
return false;
});
+
+ // check if checkboxes need to be disabled or not
+ $('.expandable').click(function(){
+ disabled = $('#categories-treeview li:first input[type=checkbox]').attr('disabled');
+ $('#categories-treeview input[type=checkbox]').attr('disabled', disabled);
+ });
}
function callbackToggle(element)
diff --git a/js/admin-products.js b/js/admin-products.js
index 53f76c1c8..ddff238e6 100644
--- a/js/admin-products.js
+++ b/js/admin-products.js
@@ -1500,6 +1500,10 @@ function multishopCheckProductField(checked, id, type)
$('#unity').attr('disabled', checked);
break;
+ case 'category_box' :
+ $('#categories-treeview input[type=checkbox]').attr('disabled', checked);
+ break;
+
default :
$('#'+id).attr('disabled', checked);
break;
@@ -1545,6 +1549,7 @@ function multishopCheckAllProductFieldsSeo(checked)
function multishopCheckAllProductFieldsAssociations(checked)
{
multishopCheckProductField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'id_category_default');
+ multishopCheckProductField($('input[name=\'multishop_check[category_box]\']').attr('checked'), 'categories-treeview', 'category_box');
}
var tabs_manager = new ProductTabsManager();