Magento – Check, Find and Get the Product Type (Simple, Configurable, Grouped, etc.)

The standard product types in Magento are Simple, Configurable, Grouped, Virtual, Bundle, and Downloadable. Have you ever wanted to change the look and feel of a product based on the product type? Or, maybe custom code a logic based on the product type? The following code will help you identify the the given product’s type.

<?php
switch ($product->getTypeId()) {
    case Mage_Catalog_Model_Product_Type::TYPE_SIMPLE:
        // Do something
        break;
    case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
        // Do something
        break;
    case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
        // Do something
        break;
    case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
        // Do something
        break;
    case Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL:
        // Do something
        break;
}
?>

Happy coding!