2010-07-08 4 views
2

Magento 핵심 클래스 인 Core/Rule/Model/Rule.php를 재정의하는 데 약간의 문제가 있습니다. 나는 모든 것을 올바르게하고 있다고 생각하지만, 코드는 작동하지 않습니다 (아무 것도 변경되지 않습니다).Magento Rule Model override

내 [네임 스페이스] /Rule/etc/config.xml :

<?xml version="1.0"?> 
<config> 
<modules> 
    <[namespace]_Rule> 
    <version>0.1.0</version> 
    </[namespace]_Rule> 
</modules> 
    <global> 
     <models> 
      <rule> 
       <rewrite> 
        <rule>[namespace]_Rule_Model_Rule</rule> 
    </rewrite> 
      </rule> 
     </models> 
    </global> 
</config> 

내 [네임 스페이스] /Rule/Model/Rule.php :

class [namespace]_Rule_Model_Rule extends Mage_Rule_Model_Rule 
{ 

    protected function _beforeSave() 
    { 

     if ($this->getConditions()) { 
      $this->setConditionsSerialized(serialize($this->getConditions()->asArray())); 
      $this->unsConditions(); 
     } 
     if ($this->getActions()) { 
      $this->setActionsSerialized(serialize($this->getActions()->asArray())); 
      $this->unsActions(); 
     } 

     $this->_prepareWebsiteIds(); 

     if (is_array($this->getCustomerGroupIds())) { 
      $this->setCustomerGroupIds(join(',', $this->getCustomerGroupIds())); 
     } 
     parent::_beforeSave(); 
    } 

내 애플의/etc/[ 네임 스페이스] _All.xml :

<?xml version="1.0"?> 
<config> 
    <modules> 
    <[namespace]_Rule> 
      <active>true</active> 
      <codePool>local</codePool> 
     </[namespace]_Rule> 

    </modules> 
</config> 

정말 도움이 될 것입니다.

답변

0

규칙 대신 SalesRule (Mage/SalesRule/Model/Rule)을 재정 의하여 문제를 해결할 수있었습니다. 규칙 모듈을 정적 (로컬/마 지막/규칙/모델/Rule.php 파일 생성) 할 때만 재정의 할 수 있습니다.

+0

SalesRule 모델을 덮어 쓰려고하는데 오버 라이딩되지 않습니다. 이에 관한 질문을 올렸습니다. 좀 도와 줄 수있어? http://stackoverflow.com/questions/7688803/magento-unable-to-override-sales-rule –