orioltestart Posted July 28, 2016 Share Posted July 28, 2016 Hi everyone, I've been working on a little module which gets executed when you add a new category and adds news categories below him. I'm getting Property Category->name is empty Can somebody help me? It's my first module. Here is the code: public function hookActionCategoryAdd($params) { $type = array("Category1", "Category2", "Category3"); if ($params['category']->calcLevelDepth() == 3) { foreach ($type as $nom) { $category_to_be_added = new Category(); $category_to_be_added->name = $nom; $category_to_be_added->is_root_category = 0; $category_to_be_added->link_rewrite = $nom; $category_to_be_added->level_depth = $params['category']->level_depth+1; $category_to_be_added->id_parent = $params['category']->id_category; if ($category_to_be_added->add(true, false, false)) { continue; } else { return false; } } } else { return false; } } Link to comment Share on other sites More sharing options...
orioltestart Posted July 28, 2016 Author Share Posted July 28, 2016 (edited) I've found the problem.. https://www.prestashop.com/forums/topic/273915-solved-category-add-by-code/ Edit: I've tried to add the names and the links_rewrite with all the languages and i don't have any error now. The problem is that the categories are added on the DB with no id_parent and doesnt show up in the categories tree view Edited July 28, 2016 by orioltestart (see edit history) 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