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); } } }