2012-02-13 84 views

回答

6

您可以重写EAV/entity_attribute资源模型像任何其他资源模型:

<global> 
    <models> 
     <eav_resource> 
      <rewrite> 
       <entity_attribute>Your_Module_Model_Eav_Resource_Entity_Attribute</entity_attribute> 
      </rewrite> 
     </eav_resource> 
    </models> 
</global> 

概念证明:

echo get_class(Mage::getResourceModel('eav/entity_attribute')); 
+0

嘿,谢谢 - 完全是这样,但发现我的覆盖不起作用的原因是因为有问题的方法是从一个子类调用 - 在这种情况下Mage_Catalog_Model_Resource_Attribute。 – srgb 2012-02-13 16:08:55

+1

所以任何想要点击属性选项保存的人都应该查找Mage_Catalog_Model_Resource_Attribute :: _ afterSave,而不是Mage_Eav_Model_Resource_Entity_Attribute :: _ saveOption – srgb 2012-02-13 16:15:49

0

正如@srgb说,覆盖Mage_Catalog_Model_Resource_Attribute_afterSave方法,而不是parent::_afterSave调用您的自定义模块资源类小时将延长Mage_Eav_Model_Resource_Entity_Attribute。在这里,您可以覆盖_saveOption方法。