Magento – Get all Attribute Sets in Static Block

attribute-setmagento-1.9

Display all atrribute sets as a dropdown list in a static block.Then selecting one, display all the products from corresponding attribute set

Best Answer

You can get all attribute set list using below code.

$entityType = Mage::getModel('catalog/product')->getResource()->getTypeId();
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection');
$attributeSetCollection->setEntityTypeFilter($entityType);
foreach ($attributeSetCollection as $attributeSet) {
    $name = $attributeSet->getAttributeSetName(); 
    $attributeSetId = $attributeSet->getId();
}

You can get Products from attribute set id as below

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addFieldToFilter('attribute_set_id', $attributeSetId);

foreach ($products as $child) {
    echo $child->getName();
}
Related Topic