Magento 2 check if product is configurable


Magento 2 check if product is configurable– It is very simple to check that product type is configurable or simple. We can get product type form product object in magento 2. Here in this article we are going to explain how you can check whether product is configurable or not.


Magento 2 check if product is configurable Example

Magento 2 check if product is configurable

You can check if product is configurable 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 == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)
{   
  echo "Configurable Product";
} 

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


Advertisements

Add Comment

📖 Read More