seaotter Posted September 14, 2011 Share Posted September 14, 2011 Hi!!! I'm trying to create a category from a module with this code: $c = new Category(); $c->active = 1; $c->name = "Test Category"; $c->id_parent = 1; $c->description = "Description"; $c->add(); $c->update(); $c->save(); The category is created, is displayed under the Home category, i can edit it, add products to it etc. The problem is: the name always is stored as "e" and the description "c". What am i doing wrong???? Link to comment Share on other sites More sharing options...
jeevanoss Posted September 14, 2011 Share Posted September 14, 2011 name & descriptions have multiple values for different langs, so they are arrays $lang_id = 1 $c->name[$lang_id] = "Test Category"; $c->description[$lang_id] = "Description"; Link to comment Share on other sites More sharing options...
seaotter Posted September 15, 2011 Author Share Posted September 15, 2011 Thanx for the quick response. I had tried with: $c->name = array((int)(Configuration::get('PS_LANG_DEFAULT')) => "Test Category"); $c->description = array((int)(Configuration::get('PS_LANG_DEFAULT')) => "Description"); but had not worked. Anyway, changing some of your answer worked perfectly. $lang_id = (int)(Configuration::get('PS_LANG_DEFAULT')); ... $c->name[$lang_id] = "Test Category"; $c->description[$lang_id] = "Description"; Thanx again 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