ansonete Posted February 26, 2011 Share Posted February 26, 2011 Hi, Im trying to add dynamically a product but i don't manage. My main issue is that i am able to add it to the database but i can never see it displayed neither in the frontend nor in the admin part. Also when i do insert it through the admin part, in the database the column "indexed" in the table "ps_product" is true, but when i do by code always false although i put the member class of the Product class to true.Any idea?Here is my code:Note: the manufacturer, supplier and category i put harcoded the ones prestashop added me by default$product = new Product();$product->name = "test book";$product->price = "10";$product->id_manufacturer=2;$product->id_supplier=2;$product->id_tax=1;$product->id_category_default=3;$product->indexed = true;$product->quantity=10;if ($product->add()){....And in here in theory my product is added, appears in the database but never anywhere in the website...Thanks in advance. Link to comment Share on other sites More sharing options...
Burhan BVK Posted February 26, 2011 Share Posted February 26, 2011 First the name property needs to be an array in the form of (id_lang=>name). Then you also need to link it with a category, even if you set the default category.$product->updateCategories(array(3));You should do that after you add the product. Link to comment Share on other sites More sharing options...
ansonete Posted February 26, 2011 Author Share Posted February 26, 2011 Oh god, now works.before i had $idCategory = 3;$product->updateCategories($idCategory)And didn't work neither, i guess of the data type (not array)..Lots of tones of thousands of thanks!You are my hero! =)Cheers. 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