문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top