Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
4885 Vizualizări

Is there a way to find what product prom model product.product is the one that is created when a product.template is created?

I don't see any field in product.product model that would define if it's a variant or not.

How can I know what is a variant and what is the base product?


Imagine profil
Abandonează
Cel mai bun răspuns

There are two possibilities:

  1. A product has no attributes, so a single record is created on product.product (dummy variant) 

  2. A product has attributes so multiple records are created on product.product (one per variant)

If you add variants to a product that didn't previously have them, the single (dummy variant) record will be archived.  This is because you can't buy or sell the product but have to use a variant.

If you want to know where a record on product.product is for a variant you could check whether  product_template_attribute_value_ids is set.  If it is, it's a variant.

Imagine profil
Abandonează
Autor

Sadly it's not that easy. You can have attributes and it's not a variant. There's an option on creating attributes, that it never creates a variant. I'm now guessing that the first record that is created is the base product, so I'm searching and ordering by ID ASC and using the first one.

Yes, there's an option not to create variants, or to only create them when you place an order.

Are you saying that there are records on product.product for attributes that aren't variants? Can you give an example?

Autor

You're kinda right. Attributes that do not create variants have no records in the product_attribute_value_product_product_rel table but only the product template has records for lines. Records are in the product_template_attribute_value table. The ones that are on the line of the product template and the product is not a variant.

Related Posts Răspunsuri Vizualizări Activitate
1
ian. 20
3861
3
mai 25
1200
3
nov. 24
7910
3
sept. 24
5797
0
dec. 17
3722