How to Check Product type is bundle by sku in magento 2?

You can check the Product type based on the SKU. If you have only product SKU and want to know about product type Bundle, you can know it easily.

First Load the Product repository by Product SKU, Call the getTypeId() method from the object and match it with Type class predefined product type constant.

Bundle product Constant defined as TYPE_BUNDLE = ‘bundle’. If your Product return type as a bundle it’s the bundle product otherwise product type is different.

Pass SKU of the product to check product type is bundle or not using Magento.

$sku = ’24-MB01′;
$product = $block->isBundleProduct($sku);

Output:
Boolean (True or false)

 

One Reply to “How to Check Product type is bundle by sku in magento 2?”

Leave a Reply