In the previous article, Getting Started With Drupal Commerce 2.x (Part — I) we have set up the Drupal commerce module 2.x and build the store. The next step to finish the basic commerce 2.x setup is to create Products.
Let’s have a detailed summary of e-commerce products creation in commerce 2.x.
1. Products :
Here we should note the main difference of Drupal Commerce 2.x (for Drupal 8) from Drupal Commerce 1.x (for Drupal 7). In Commerce 2.x, we now have such entities as Product and Product Variation. The product replaces product display of Commerce 1.x (node type, which has been linked to the products).
1.1 Product Attributes:
In Commerce 2.x product attributes is a drupal entity, So it is easy to edit, delete, create new attribute from.
To create commerce Products, first, we need to create Product attributes. On the Product Attributes page (admin/commerce/product-attributes) we add our attribute (eg, product size) and select a value that it can have.
For example, let’s add “size”.
1.2 Product variations:
The Product variation types page (admin/commerce/config/product-variation-types) we choose the Default product variation (or create our own), and add this attribute to the variation
A product variation can have several attributes. All the attributes of the product variations can be found in the list of fields (admin/commerce/config/product-variation-types/default/edit/fields). When creating a new type of product variations, you can use the already existing attributes.
In our example, the Default variation has one attribute — “size”. This is a field that can be changed just like other fields. By clicking the Edit button, we can go to the editing mode.
So for Size As an example, let’s set a default value.
A product variation may have various fields of different types (text, numeric, etc.), as well as other entities
1.3 Product Types
The Product types page (admin/commerce/config/product-types) we choose the Default product type (or create our own), and here we can add fields which will be added with the product entity. In manage fields in default product type (admin/commerce/config/product-types/default/edit/fields) we see Variations and Store are inherited in product and Body is a field added to it.
Let’s add an image field too
These fields will be seen when we add products, which is the next step.
1.4 Creating Product:
Instead of nodes, we hare having Product entity itself. To create a product, let’s go to the admin/commerce/products page. We will have a product named “T-shirt” and the variations of this product in various sizes.
This is how our first product looks.
We have now done basic settings for an online store. The Drupal Commerce 2.x module supports a variety of options for implementing the desired features like shipping (commerce shipping module), Promotions (commerce promotions module). Recently Commerce guys are working on making these functionality stable.