ballashop Posted March 17, 2022 Share Posted March 17, 2022 Hi, when I create a customer group I then have to enable it for all the existing categories, is there a massive way to do it? Thanks for any reply. Balla Link to comment Share on other sites More sharing options...
Ress Posted March 17, 2022 Share Posted March 17, 2022 Hi, I have developed a module to solve this problem. https://github.com/PrestaManiacs/thupdcatgroup Link to comment Share on other sites More sharing options...
ballashop Posted March 17, 2022 Author Share Posted March 17, 2022 Hi @Ress thanks for the link, is it possible to do this without using external modules? for example by importing a csv file? Thanks for any reply. balla Link to comment Share on other sites More sharing options...
Ress Posted March 17, 2022 Share Posted March 17, 2022 Hi, With the default import functionality of PrestaShop you can't. Link to comment Share on other sites More sharing options...
ballashop Posted March 17, 2022 Author Share Posted March 17, 2022 Hi @Ress thanks. about your module can I try it? is it available for 1.7.x? Thanks. Balla Link to comment Share on other sites More sharing options...
ps8modules Posted March 17, 2022 Share Posted March 17, 2022 https://www.google.com/amp/s/www.mediacom87.fr/en/amp/how-to-automatically-associate-all-categories-to-a-new-customer-group-on-prestashop-17/ 2 Link to comment Share on other sites More sharing options...
ballashop Posted March 17, 2022 Author Share Posted March 17, 2022 @4you.software thanks a lot, very interesting, I'll try and I'll let you know. Balla 1 Link to comment Share on other sites More sharing options...
ballashop Posted March 17, 2022 Author Share Posted March 17, 2022 2 hours ago, 4you.software said: https://www.google.com/amp/s/www.mediacom87.fr/en/amp/how-to-automatically-associate-all-categories-to-a-new-customer-group-on-prestashop-17/ Hi @4you.software I'm trying to make the suggested change on the link but is not clear to me where I have to insert the first code, can you kindly suggest me? Thanks for any reply. Balla Link to comment Share on other sites More sharing options...
ps8modules Posted March 17, 2022 Share Posted March 17, 2022 ./controllers/admin/AdminGroupsController.php 1 Link to comment Share on other sites More sharing options...
ballashop Posted March 17, 2022 Author Share Posted March 17, 2022 20 minutes ago, 4you.software said: ./controllers/admin/AdminGroupsController.php Hi @4you.software sorry but I explained myself wrong, not which file but inside the code, exactly where does the change go? Unfortunately, from the tutorial, on the first code it doesn't show exactly where thanks for any reply. balla Link to comment Share on other sites More sharing options...
ps8modules Posted March 17, 2022 Share Posted March 17, 2022 (edited) 1. find function renderForm() 2. add before 'type' => 'group_discount_category [ 'type' => 'switch', 'label' => $this->trans('Show prices', [], 'Admin.Shopparameters.Feature'), 'name' => 'show_prices', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => [ [ 'id' => 'show_prices_on', 'value' => 1, 'label' => $this->trans('Yes', [], 'Admin.Global'), ], [ 'id' => 'show_prices_off', 'value' => 0, 'label' => $this->trans('No', [], 'Admin.Global'), ], ], 'hint' => $this->trans('Customers in this group can view prices.', [], 'Admin.Shopparameters.Help'), 'desc' => $this->trans('Need to hide prices for all groups? Save time, enable catalog mode in Product Settings instead.', [], 'Admin.Shopparameters.Help'), ], [ 'type' => 'switch', 'label' => $this->trans('Assign to all categories', [], 'Admin.Shopparameters.Feature'), 'name' => 'all_cat', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => [ [ 'id' => 'all_cat_on', 'value' => 1, 'label' => $this->trans('Yes', [], 'Admin.Global'), ], [ 'id' => 'all_cat_off', 'value' => 0, 'label' => $this->trans('No', [], 'Admin.Global'), ], ], 'hint' => $this->trans('Customers in this group can access to all categories. Leave on "NO" if you want to assign them manually.', [], 'Admin.Shopparameters.Help'), ], 3. find function processSave() 4. add after $this->updateRestrictions(); 5. create new function after processSave() public function access_all($group) { $id_group = (int)$group->id; $assign_to_all = (bool)Tools::getValue('all_cat'); $get_categories = Db::getInstance()->executeS('SELECT id_category FROM '._DB_PREFIX_.'category WHERE id_category > 1;'); if ($assign_to_all && $id_group && $get_categories) { foreach ($get_categories as $category){ Db::getInstance()->insert('category_group', array( 'id_category' => (int)$category['id_category'], 'group' => (int)$id_group ),false, true, Db::INSERT_IGNORE); } } } Edited March 17, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ballashop Posted March 25, 2022 Author Share Posted March 25, 2022 hi and sorry for my late, I'll try asap. Thanks a lot. Balla Link to comment Share on other sites More sharing options...
Stefan.K Posted May 17, 2023 Share Posted May 17, 2023 On 3/17/2022 at 6:15 PM, ps8moduly.cz said: 1. find function renderForm() 2. add before 'type' => 'group_discount_category [ 'type' => 'switch', 'label' => $this->trans('Show prices', [], 'Admin.Shopparameters.Feature'), 'name' => 'show_prices', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => [ [ 'id' => 'show_prices_on', 'value' => 1, 'label' => $this->trans('Yes', [], 'Admin.Global'), ], [ 'id' => 'show_prices_off', 'value' => 0, 'label' => $this->trans('No', [], 'Admin.Global'), ], ], 'hint' => $this->trans('Customers in this group can view prices.', [], 'Admin.Shopparameters.Help'), 'desc' => $this->trans('Need to hide prices for all groups? Save time, enable catalog mode in Product Settings instead.', [], 'Admin.Shopparameters.Help'), ], [ 'type' => 'switch', 'label' => $this->trans('Assign to all categories', [], 'Admin.Shopparameters.Feature'), 'name' => 'all_cat', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => [ [ 'id' => 'all_cat_on', 'value' => 1, 'label' => $this->trans('Yes', [], 'Admin.Global'), ], [ 'id' => 'all_cat_off', 'value' => 0, 'label' => $this->trans('No', [], 'Admin.Global'), ], ], 'hint' => $this->trans('Customers in this group can access to all categories. Leave on "NO" if you want to assign them manually.', [], 'Admin.Shopparameters.Help'), ], 3. find function processSave() 4. add after $this->updateRestrictions(); 5. create new function after processSave() public function access_all($group) { $id_group = (int)$group->id; $assign_to_all = (bool)Tools::getValue('all_cat'); $get_categories = Db::getInstance()->executeS('SELECT id_category FROM '._DB_PREFIX_.'category WHERE id_category > 1;'); if ($assign_to_all && $id_group && $get_categories) { foreach ($get_categories as $category){ Db::getInstance()->insert('category_group', array( 'id_category' => (int)$category['id_category'], 'group' => (int)$id_group ),false, true, Db::INSERT_IGNORE); } } } If anyone copies this please update the insert statement in access_all to : Db::getInstance()->insert('category_group', array( 'id_category' => (int)$category['id_category'], 'id_group' => (int)$id_group ),false, true, Db::INSERT_IGNORE); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now