Using Products and Standard Product Types (simple, configurable, bundled, etc.) in Magento 2

Oct 18, 2018791Andrey Litvin
Using Products and Standard Product Types (simple, configurable, bundled, etc.) in Magento 2

Magento 2 offers 6 types of products so that store owners could choose among them according to the specifics of their business. Let’s take a look at each of the 6 types of products in Magento 2 and learn the basic methods for different types of products and some additional functionality for particular types.

Product types in Magento 2

There are 6 types of products:
1) Simple Product. It’s the most popular basic type of products. It corresponds to the existing product with a unique SKU (Store Keeping Unit).

Using Products and Standard Product Types in Magento 2

2) Virtual Product. This type of product is used to create products that are not physically present on the store (paid subscriptions, services, insurance, etc.).

Using Products and Standard Product Types in Magento 2

3) Configurable Product. This type allows you to create products with a list of variations. For example, a sports T-shirt of different colors and sizes. Each variation of a configurable product corresponds to a Simple Product, which has its own unique SKU, which allows you to keep track of the residuals for each option.

Using Products and Standard Product Types in Magento 2

4) Grouped Product. This type allows you to combine into sets individual Simple or Virtual Products, that are somehow related to each other. As a result, a buyer gets an opportunity to buy all the needed products at once, instead of buying them separately. On the page of a Grouped Product customers can choose particular products that they would like to purchase from the set, as well as their quantity. The selected products are added to cart as individual items.Here is an example of a Grouped Product. There are 6,8 and 10-foot Yoga Straps. Customers can choose the one they need and enter the required quantity into the Qty box on the right.

Using Products and Standard Product Types in Magento 2

5) Bundle Product. This type of product allows customers to independently “create” a product using a set of options. Here is an example of a yoga kit.

Using Products and Standard Product Types in Magento 2

Each option is a Simple Product or a Virtual Product. Before adding this product to cart, buyers must first customize it using a set of predefined options, and the final price will depend on their choice.

Using Products and Standard Product Types in Magento 2

The SKU and Weight attributes can be fixed or dynamic. The price for the Bundle Product can be set as Price Range (a price range from minimum to maximum) or As Low As (the lowest possible price). Administrators can specify how parts of the Bundle Product will be delivered — together or separately.

6) Downloadable Product. This type of product is used to create digital products that can be represented by one or multiple files and can be downloaded by customers.

Using Products and Standard Product Types in Magento 2

Virtual and Downloadable Products have no weight, therefore there is no need to choose the delivery method for these products at checkout. Also, Virtual and Downloadable Products do not have the In Stock attribute.

To get all the products of a particular type, you can use the Magento\Catalog\Model\ResourceModel\Product\Collection class:

$collection->addFieldToFilter(‘type_id’, ‘bundle’);

Type the name of the required product as a second parameter: bundle, configurable, downloadable, grouped, simple or virtual.

Basic Methods for different types of products in Magento 2

Basic methods available for different types of products:

  • getSetAttributes — returns a set of product attributes;
  • getAttributeById — returns an attribute by its id and the product id;
  • isVirtual — determines whether the product is virtual;
  • isSalable — determines whether a product is salable;
  • isComposite — determines whether a product is compound;
  • canConfigure — checks if the product is configurable;
  • prepareForCart — initializes the proccess of adding a product to cart;
  • checkProductBuyState — checks whether it is possible to buy a product;
  • getSku — returns product SKUs;
  • hasOptions — checks if the product has options;
  • hasWeight — checks if the product has weight;
  • getRelationInfo — returns the information about product relations;
  • getAssociatedProducts — returns associated products;
  • getChildrenIds — returns the child product ids;
  • getParentIdsByChild — returns the list of parent product ids;
  • assignProductToOption — assigns options to a product.

Additional functionality for certain product types

Configurable:

  • getConfigurableAttributes — returns the attributes used for subproducts;
  • getUsedProductIds — returns subproduct ids;
  • getProductByAttributes — returns a product by attribute values;
  • getConfigurableOptions — returns a list of options;
  • setImageFromChildProduct — sets a child product image for a parent product, if it has not been previously uploaded.

Bundle:

  • getOptions — returns a list of options;
  • getSelectionsCollection — returns a collection of options by their id;
  • getSpecifyOptionMessage — returns a message to a buyer with a requirement to specify the options;
  • checkIsAllRequiredOptions — checks if all the required options have been selected;
  • checkSelectionsIsSale — checks if all the options are available for sale.

Downloadable:

  • getLinks — returns the download links to a product;
  • hasLinks — checks if a product has download links;
  • getLinkSelectionRequired — checks if a product can be purchased without the selected links;
  • getSamples — returns download samples to a product;
  • hasSamples — checks if a product has download samples.

It should also be noted that although methods like getRelationInfo, getAssociatedProducts, getChildrenIds, getParentIdsByChild, etc. are common to all types of products, they return an empty array for non-composite types (Simple, Virtual). The logic of these methods is implemented in classes of complex types according to the specifics of this type.



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *