Tag Archives: We can check 2 ways if a product is a simple product and does not a child of any configurable product

how to check product is a simple product

We can check 2 ways if a product is a simple product and does not a child of any configurable product

Way-1:-

$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($productId);

if (!count($parentIds)) {
// Product is Simple product
}

It return the product parent Ids. if it does not return any parent product ids that means the product is Simple product.

Way-2:- Check by product Attribute set Id.

$sPro = Mage::getModel('catalog/product')->load($productId);

$attributeSetName = Mage::getModel("eav/entity_attribute_set")
->load($sPro->getAttributeSetId())
->getAttributeSetName();

if($attributeSetName=='Default' && $sPro->getTypeId()=='simple') {
      echo "simple product";
}

The Way-1 is fastest then Way-2.