Jump to content

How to edit product combinations values like reference, ean etc by object


hakeryk2

Recommended Posts

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 by hakeryk2 (see edit history)
Link to comment
Share on other sites

  • 4 months later...
  • 2 years later...
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...