How to get simple products of configurable product in Magento 2

- E-Commerce, Magento 2

Magento 2 simple products of configurable product

The following article sheds light on how to get simple products out of a configurable product in Magento 2. This technique is necessary for frontend pages to display product information stored in simple product attributes exclusively. At the same time, you can streamline it to calculate the number of simple products associated with a configurable one.

How to get simple products of configurable product in Magento 2

Although there are many reasons to use Magento 2 when you want to run an e-commerce business, the simplicity of configurable products attracts more and more merchants to the platform. And the desired functionality is available by default!

As a store administrator, you can leverage the out-of-the-box functionality of Magento 2 to decide on which attribute the simple to configurable product association is based. The platform lets you use a single attribute to create the most straightforward configurable products (a particular model of snickers available in different sizes) or leverage a bunch of them (t-shirts available in different sizes and colors). Only a few e-commerce platforms provide similar options, but they are quite expensive. You can read more about configurable products in this guide: The Complete Guide to Magento 2 Configurable Products. Let’s return to our mutton and find out how to get simple products out of a configurable product in Magento 2. 

Below, we provide a code sample from the article published in the Magento2 Blog. It shows how to load a configurable product with the help of the object manager get all child products as an array. Under child products, we assume all simple products associated with a configurable one, which is a parent product. Here is the sample code snippet:

Use it to load a configurable product by its product_id with the help of the object manager. Consider using Magento 2 injections! 

If you want to get an array of associated simple products, you only need to call getUsedProducts() from the objects type instance. 

Also, note that the code snippet prints out simple products by IDs as well as displays their sum.

While your frontend may display only configurable products, hundreds of simple child items associated with a single configurable parent may be hidden. Each configurable product combination requires a separate single simple product. Thus, the more configurable attributes and attribute options you have, the higher number of simple products you have to utilize. 

But you can easily display all the corresponding information on the frontend before the selection of a simple product. Just use the code snippet above.

Other Configurable Product Improvements

To use configurable products to full potential – take advantage of B2B bulk ordering, dynamic attribute changes, improved SEO, advertising options, etc. – you need to install a third-party extension. Although the default functionality of configurable products is impressive, there is still room for improvement. Therefore, we recommend you to pay attention to the Improved Configurable Product Magento 2 extension. The module offers the following features and enhancements:

  • Dynamic content update for category and product pages. Every time a new option is selected, the extension changes a page URL, product name, SKU, description, and other attributes without reloads;
    Magento 2 simple products of configurable product
  • Flexible product price range display is utilized to inform customers about the minimal and maximal price of the configurable product option;
    Magento 2 simple products of configurable product
  • Default variation of a configurable product dramatically simplifies shopping since you can provide the most popular option configuration out-of-the-box;
    Magento 2 simple products of configurable product
  • Matrix grid for configurable product options enables bulk ordering – a strong B2B feature that allows customers to purchase multiple product options from a single page simultaneously;
    Magento 2 simple products of configurable product
  • Enhanced bundle enables you to add configurable products to Magento 2 bundle products;
  • Custom options for configurable products are supported!
    Magento 2 simple products of configurable product
  • Product options pre-select with page URL enables simple sharing of each configurable product option;
  • Target advertising of specific products;
  • Full support for tier and group prices;
  • Custom shipping logic;
  • SEO features with metadata and Schema.org dynamic updates.

Now, let’s describe the extension’s core improvements individually.

Product matrix

Magento 2 Configurable Product Matrix grid lets customers add multiple product options to the cart simultaneously, enabling Magento 2 quick order functionality. As a store administrator, you can allow tier prices in the matrix grid as well as the display of product quantity. Thus, it’s a must-have B2B improvement unavailable in Magento 2 by default. 

Every wholesaler with configurable products can dramatically improve the lives of their customers but introducing the enhanced shopping experience.  The Magento 2 Improved Configurable Products extension eliminates the necessity to add each product option to the cart individually. Instead, customers can place multiple options of the same configurable product simultaneously. Such a vital enhancement dramatically speeds up the ordering process. 

As you can see, the Improved Configurable Product extension also adds the ‘Available Qty’ column to the grid, informing your clients about the number of available configurable product options. 

Each option also includes a stock status and individual price. Furthermore, you can enable tier prices for the grid.

Enhanced bundles

With our extension, you can also add configurable products to bundle product options without any headaches. After the module is installed, you can find the corresponding option in bundle configurations.

On a bundle product page, customers can use the ‘customize’ button to select necessary options, which are displayed as thumbnails. Although only one configurable product variation can be added to the cart at a time, multiple bundle options are possible. Thus, a customer can add multiple bundle variation to cart one by one.

Custom shipping logic

Another vital feature of the Improved Configurable Product Magento 2 extension is the ability to display custom messages for every option of a configurable product.

The module shows a specified message if the current date of the customer’s visit to the product page is between the specified start and end date set per product. Thus, you inform customers about the possible delivery date of in real-time.

Conclusion

As you can see, there is nothing complicated in getting simple products out of a configurable product in Magento 2. Furthermore, you can enable multiple new features and possibilities with our extension. Follow the link below and contact our support for further information:

Get Improved Configurable Product Magento 2 Extension