2012-02-13 72 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方法。