Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
4868 Widoki

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?


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
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.

Powiązane posty Odpowiedzi Widoki Czynność
1
sty 20
3837
3
maj 25
1177
3
lis 24
7883
3
wrz 24
5768
0
gru 17
3708