Jump to content

Update all categories with new customer groups


Recommended Posts

Hi all,
is it possible to include or adapt php code to show in back office.
I mean, I create controller and make Update button to menu of back office and want to include this code to show there

$new_group = $_POST["new_group"];
$categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
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);
echo 'Updated';
<form method="post" action="'.$_SERVER["PHP_SELF"].'">
Enter New Group id: <input type="text" name="new_group">
<input type="submit" name="update" > 

thnx in advance

Link to comment
Share on other sites

Thnx Eric,


I tried but don't know how get this to work.  :unsure:

I tried in this way that create menu button in BO, make controller to call tpl file, but as I saw there is no possibility to include php functions in tpl file.


Do you have some working example or something else to help me?


thnx in advance


Link to comment
Share on other sites

Hi Dani,


Did you have a look at the developers guide already? There is some example on how to make a module, and in there, they describe how to add some configuration page, where you add some input fields to modify, and a submit button. There you can see how they act on a submit as well.


On creating a module:



and a direct link for how to add the configuration page:



Hope this helps,


Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...