hakeryk2 Posted June 19, 2017 Share Posted June 19, 2017 (edited) Hello devs, How in object way I can edit, modify or create product combinations? What param and what class should I call to get combination object by id_product_attribute or by reference? In product it is like this: $p = new Product(id); $p->reference = 'New reference'; $p->save; But I don't know to get to product combinations. In example I have product with 5 combinations and I would like to change reference code in them. How I can achieve that? EDIT-------------------------------------------------------- Ok, I found it. $combination = new Combination($id_product_attribute, ContextCore::getContext()->shop->id, ContextCore::getContext()->language->id); $combination ->reference = 'new_ref'; $combination ->save(); Edited June 19, 2017 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
TWP Posted November 14, 2017 Share Posted November 14, 2017 Which file did you make the change? Link to comment Share on other sites More sharing options...
hakeryk2 Posted November 21, 2017 Author Share Posted November 21, 2017 It is not about which file because I was developing my custom module so You can use whatever You want and You have id of product or combination. Link to comment Share on other sites More sharing options...
Ezequielb Posted April 13, 2020 Share Posted April 13, 2020 On 6/19/2017 at 5:57 AM, hakeryk2 said: Hello devs, How in object way I can edit, modify or create product combinations? What param and what class should I call to get combination object by id_product_attribute or by reference? In product it is like this: $p = new Product(id); $p->reference = 'New reference'; $p->save; But I don't know to get to product combinations. In example I have product with 5 combinations and I would like to change reference code in them. How I can achieve that? EDIT-------------------------------------------------------- Ok, I found it. $combination = new Combination($id_product_attribute, ContextCore::getContext()->shop->id, ContextCore::getContext()->language->id); $combination ->reference = 'new_ref'; $combination ->save(); You create the reference number for the new combinations with this approach? 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