Jump to content

Script for enable all categories to new group: does it works for PS 1.5.6?


Recommended Posts

Hi all,

in this post (http://www.prestashop.com/forums/topic/196928-help-new-group-of-customers-enable-all-categories-automatically/) Valérie Assetskaya posted this script.

 

Any idea if it works fine  for PS 1.5.6?

 

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

?>

 

Link to comment
Share on other sites

×
×
  • Create New...