0

From the docs :

Products variations can have attributes and other kinds of fields. Going back to our t-shirt analogy from above, if our t-shirts come in sizes and colors, perhaps the product variation should have an image field so you can upload a picture of a small red shirt. These kinds of non-attribute fields are loaded dynamically when variations are chosen.

What is the difference of purpose and meaning of "non-attribute fields" AND attributes ? How are they different and similar ?

3

The way I think about it is in terms of sku numbers (or manufacturing part number/catalog number.) If a single product is available in multiple sizes (1 mg, 50 mg, 1 gm), each one will have its own unique sku. Those sizes are the variation attributes. But then I may also want to add on a non-attribute field like an image or a packaging/shipping surcharge (for a larger size). That data is specific to the product variation but isn't related to the sku.

Using the t-shirt analogy, if both size and color are attributes, then you might have the following unique variations:

  • TS_SM_01: small, blue t-shirt
  • TS_MD_01: medium, blue t-shirt
  • TS_LG_01: large, blue t-shirt
  • TS_SM_02: small, red t-shirt
  • TS_LG_02: large, red t-shirt
  • TS_SM_03: small, green t-shirt
  • TS_MD_03: medium, green t-shirt
  • TS_LG_03: large, green t-shirt

If I add on a field for an image or a field for some sort of customization, those new "non-attribute" fields do not cause me to create a whole new set of product variation sku numbers.

  • I'd like to add that non-attribute fields such as an image (and the default price field) will update once a variation changes. So as soon as you change color, you can also change the image preview, price, etc. If you would place the image field on the product instead, it would also display, but not update once the selection changes. – Neograph734 Jun 27 '17 at 21:20
3

Hey there :) I wrote the above documentation a year or two ago. I think your question has two parts:

1. What is an attribute?

In the simplest terms possible, an attribute is something that differentiates your products at the SKU level.

An attribute for Drupal 8 is actually an entity, like a product or a piece of content. It's a specialized entity that has a specialized form for creation and management because the majority of product variations on Drupal Commerce 1.x needed something like what we built for 2.x.

One of the use cases we wanted to meet was the ability to add fields to attributes. So color or size are often used to describe an attribute. A color might need a field for a photorealistic representation of the color and a hexadecimal field that describes the color within the RGB spectrum.

2. In terms of entity architecture, why would I choose to make a differentiator an attribute? And the opposite situation?

When creating product variations, you can choose to create any number of fields. Sometimes those fields are best off being attribute references. Using attribute references lets the add-to-cart form understand the nature of your products and can help give you a configurable product form. This lets you pick the color and size combinations instead of picking from a long list of products with both colors and sizes pointed out.

In the end, no one is forcing you to use the attributes to document the differentiators. If you want to create an integer field per SKU that defines the length of the fabric you're selling, that doesn't have to be an attribute, but it could be a part of the pricing. (final price could be length x price)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.