In the Simple product type documentation, we added a custom field to a product variation type, to allow product variations to have images. In the Product type with attributes documentation, we added a custom field to a product attribute, to allow a Color attribute to be displayed as a color swatch image instead of just the color name. In this section, we're going to look at how to add fields to product types so that we can organize products into categories that can be used for the product catalog.
Let's start by creating a "Brands" taxonomy to organize products by brand.
(need to add in some links to this section) For our product catalog, we're also going to want to hierarchical categories so that customers can use faceted search to "drill down" to specific categories. For example, on the Commerce Demo site, we have an "Urban Living" product category with sub-categories of "Food & Beverage", "Home", "Outdoors", etc. And within the "Home" category, we further classify products as "Accessories", "Kitchen", "Office", or "Furnishings".
To create a hierarchical taxonomy in Drupal, we can use the same steps we used to create a "basic" taxonomy. After creating a "Product categories" taxonomy and adding the terms, we have a listing that looks like this:
Notice that the "Accessories" term appears to be duplicated, but that's fine, since one of those terms will be a sub-category of the Urban Living "Home" category, and the other will be a sub-category of the Urban Living "Outdoors" category. They have the same label but are actually two completely separate terms.
To transform this simple listing into a hierarchical taxonomy, you just need to use the drag-and-drop icons in the leftmost column to rearrange the terms. You may also find it helpful to click the "Show row weights" link to set the order of terms within a particular category, especially if there are a great number of items. After moving items around, the Product categories taxonomy now looks like this and all we need to do is click the "Save" button to save the changes:
Let's add a field that references our "Brands" taxonomy to both our Simple product type.
The "Brand" field has now been added to the Simple product type. To add the Brand field to another product type, you can "Re-use an existing field" to select this Brand field on the "Add field" page for the product type.
We can also create a new Taxonomy term reference field for our "Product categories" taxonomy and any other product taxonomies we want to create. Unlike the "Brand" field, which was limited to a single value, we'll specify "Unlimited" for the "Allowed number of values" for product categories:
(Link to pages like faceted search/product catalog, etc. for "how to use" these taxonomies.)
In the next section, we'll look at options for product architectures in Drupal Commerce.
Found errors? Think you can improve this documentation? edit this page