janskopljak Posted June 8, 2016 Share Posted June 8, 2016 So I've been dealing with this problem for quite some time and can't find a clear solution. So basically I'm adding new products directly into db using Product object. For now it went well but I can't manage to link new products with a category. $cat_ids = []; foreach ($value['kat_naziv'] as $cat_val) { $cat_ids[] = (int)$luceed->selectCategoryIds($cat_val)[$cat_val]['id_category']; } $product->id_category = 3; $product->id_category_default = 3; $product->save(); $product->addToCategories($cat_ids); So basically $cat_ids is an array of integers that i'm getting from db where name is something i pass as a parameter to selectCategoryIds; What is the problem here why it wont associate newly created product with categories i give to it 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