I'm trying to figure out how to identify stray attributes that do not belong to an attribute set.

We've got so many duplicate attributes, and we're having a hard time figuring out what is actually being used.

Also I heard that having lots of attributes will slow down the site. If we can delete the attributes we are not using, that would certainly help.

Please advise.


Please add bellow script on magento root. Eg file (xyz.php) and run this file in browser then results are attributes that do not belong to an attribute set.


class AR
    public function index()    
        //$attributeSetIds = array(4);
        $attributeSetIds = Mage::getModel('catalog/product')->getDefaultAttributeSetId(); 
        $collection = Mage::getResourceModel('catalog/product_attribute_collection')

        $attributesIds = array('0');
        /* @var $item Mage_Eav_Model_Entity_Attribute */
        foreach ($collection->getItems() as $item) {
            $attributesIds[] = $item->getAttributeId();

        $attributes = Mage::getResourceModel('catalog/product_attribute_collection')

       $html .= '<h2>Product(s) Unassigned Attributes List</h2>';
       $html .= '<table style="border-style: solid solid solid; border-width: 1px 1px 1px; width: 100%;">
                        <th>Attribute ID#</th>
                        <th>Attribute Label</th>
                        <th>Attribute Code</th>
       if(count($attributes)) {
           foreach ($attributes as $attribute) {
               $html .= '<tr>';
               $html .= '<td align="center">'.$attribute->getAttributeId().'</td>';
               $html .= '<td align="center">'.$attribute->getFrontendLabel().'</td>';
               $html .= '<td align="center">'.$attribute->getAttributeCode().'</td>';
               $html .= '</tr>';
       }else {
          $html .= '<tr class="even"><td colspan="3" align="center">Attribute(s) not found.</td></tr>';

       $html .= '</tbody></table>';
       echo $html;

    public function removeAttribute($code='')
        $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
        $entityTypeId = (int) $installer->getEntityTypeId('catalog_product'); 
        $installer->removeAttribute($entityTypeId ,$code);

$obj = new AR();

Also i have added remove attribute code in above script but right now it is commented

Note: Please always backup your database after use script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.