Oct 22, 2014

Posted by in Magento, Technology | 0 comments

How to get and compare product type in magento

We can use the following code to get product type in Magento
$product_id = $this->getProduct()->getId(); //currently loaded product id - can be replaved with any dynamic variable/value

//get product collection
$_product = Mage::getModel('catalog/product')->load($product_id);

//get product type
$productType = $product->getTypeID();

//compare variaous product types
if($productType == 'simple') {
//THIS IS A SIMPLE PRODUCT
}
else if($productType == 'grouped') {
//THIS IS A GROUPED PRODUCT
}
else if($productType == 'configurable') {
//THIS IS A CONFIGURABLE PRODUCT
}

Leave a Reply