Search code examples
magentoconfigurable-product

How to check if a product is a simple product


I know how to check if a product is configurable or not. I also got how to check if a simple product is a child of a configurable product or not. But can anyone tell me how to check if a product is a pure simple product?

That means that I want to check those products which I created as Attribute set='Default' and Product type='Simple Product' not attribute set='Default' and Product type='configurable Product'.


Solution

  • Try this

    $attributeSetModel = Mage::getModel("eav/entity_attribute_set")->load($product->getAttributeSetId());
    $attributeSetName  = $attributeSetModel->getAttributeSetName();
    
    $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
    
    if ($product->getTypeId() == 'simple' && empty($parentIds) && $attributeSetName == 'Default') {
        echo "This is a simple product with no parent configurable product in the 'Default' attribute set";
    };