Tutorialsplane

Magento 2 check if product type is grouped


Magento 2 check if product type is grouped– We sometimes need to check the product type is “group product” or not. We can check get product type grouped using product type id property. Here in this tutorial, we are going to explain how you can check whether a product is grouped or not in Magento 2.


Magento 2 check if product type is grouped Example

You can check if product type is bundle or not simply as below-

Example:

$productId = 199;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load($productId);
$productType = $product->getTypeID();

if($productType == "grouped")
{   
  echo "Product is Group Product";
} 

$productType will give you “grouped” which means product type is grouped.