2012-01-19 3 views
8

Enterprise 섹션에있는 옵저버에서 기능을 다시 작성해야 할 때 config.xml에서 비트 재 작성 방법은 어떻게됩니까?Magento Gift Card 옵저버 기능 다시 쓰기

이게 뭔가요?

<global> 
    <models> 
     <enterprise> 
      <rewrite> 
       <giftcard>Custom_GiftCard_Model_Observer</giftcard> 
      </rewrite> 
     </enterprise> 
    </models> 
</global> 

내 클래스는 다음과 같이 선언한다 : 클래스 Custom_GiftCard_Model_Observer 나는 순간 엔터프라이즈 개발 환경 설정이없는

답변

17

Enterprise_GiftCard_Model_Observer { ..... }를 확장, 그래서이 안된 , 설명 된대로 작동해야합니다. 당신이

app/code/core/Enterprise/GiftCard/etc/config.xml 

에서 기프트 카드 구성을 보면 당신은

에 대해 grep을하고 enterprise_giftcard/observer의 클래스 별명,

<class>enterprise_giftcard/observer</class> 

그래서 기프트 카드 관찰자의 클래스 별칭을 발견 할 수 있습니다 모델 그룹 이름이 enterprise_giftcard이고 모델 클래스 이름이 observer입니다. 모듈의 구성 파일에서

, 먼저, 당신은 당신이 다시하려는 클래스의 그룹 이름을 추가 할 것입니다,

<global> 
    <models> 

    </models> 
</global> 

그리고 모델 구성을위한 영역을 만듭니다 enterprise_giftcard

<global> 
    <models> 
     <enterprise_giftcard> 
     </enterprise_giftcard> 
    </models> 
</global> 
다음

, 당신은 당신이이 그룹에서 하나의 클래스를 다시 할 말 노드를 추가 할 것입니다

<global> 
    <models> 
     <enterprise_giftcard> 
      <rewrite> 
      </rewrite> 
     </enterprise_giftcard> 
    </models> 
</global> 
,691 ( observer)

<global> 
    <models> 
     <enterprise_giftcard> 
      <rewrite> 
       <observer></observer> 
      </rewrite> 
     </enterprise_giftcard> 
    </models> 
</global> 

그리고 마지막으로,이 노드 내에서, 당신은 추가 할 것

, 당신은 클래스 별칭의 이름 부분을 사용하여, 당신은 다시하고자하는 그룹의 어느 클래스를 나타내는 노드를 추가 할 것 새 클래스의 이름 인 텍스트 노드.

<global> 
    <models> 
     <enterprise_giftcard> 
      <rewrite> 
       <observer>Custom_GiftCard_Model_Observer</observer> 
      </rewrite> 
     </enterprise_giftcard> 
    </models> 
</global> 

당신은 내가 UR 추종자 해요 직접 관찰자의 인스턴스를, 그 클래스 이름

$model = Mage::getModel('enterprise_giftcard/observer'); 
var_dump(get_class($model)); 
+0

잘 설명을 선택하여 재 작성을 테스트 할 수 있습니다. – Gowri

+0

빠른 응답을 주셔서 감사합니다. 그것을 빨리 시험해 볼 것입니다. – ShaunOReilly

+0

그 일을했다, 고마워. 나는 머리카락을 꺼내려고했다. 왜냐하면 나는 기본을 잊어 버렸기 때문이다! – ShaunOReilly