Jump to content

[HELP] new group of customers. Enable all categories automatically


Recommended Posts

  • 2 weeks later...

Hi,

 

It is necessary to create a file in PrestaShop root (updCategoryGroup.php), and call it, it can be done even from browser line -myStore.com/updCategoryGroup.php

Then add the following code:

 

<?php

 

require(dirname(__FILE__).'/config/config.inc.php');

 

$new_group = 4; // there is ID of new group

$categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('

SELECT DISTINCT c.*

FROM `'._DB_PREFIX_.'category` c

LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')

');

 

foreach($categories as $category){

$categoryObj = new Category($category['id_category'], (int)Context::getContext()->language->id);

$categoryObj->addGroups(array($new_group));

}

 

Best regards.

  • Like 2
Link to comment
Share on other sites

  • 3 months later...
  • 8 months later...
  • 4 weeks later...
×
×
  • Create New...