Pergunta

There's 'Default' attribute set in the default Magento installation. You have no ability to remove that attribute set using admin gui (Remove button is hidden for this set). I did not found something like system flag or other singularities for this set in eav_attribute_set. I need an ability to detect this attribute set's id programmatically in different installations. Maybe someone faced with task like this one and could give me the clue. Thanks

Foi útil?

Solução

This should give you what you need:

Mage::getModel('catalog/product')->getDefaultAttributeSetId();

Additional info: The default attribute set id is stored in the table eav_entity_type for each entity. The sales related entities have this set to 0 because they are stored in flat tables now. But before ce-1.4.0.1 they were EAV also and had an attribute set.

Outras dicas

A better answer would be this:

Mage::getModel('my_module/my_entity')->getResource()->getEntityType()->getDefaultAttributeSetId();

Marius's answer is also good, but only works for products and not for custom EAV models you may have created.

My answer works for all EAV types, including custom ones.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top