2014-04-16 2 views
0

먼저, 여기에 대답은 매우 도움이된다 : 거기에 대한 답변에서 언급 한 "시험"을 모두 통과에도 불구하고, Overriding a Magento Controller in community extention문제 재정 젠토 커뮤니티 모듈 컨트롤러 모두의

그러나, 나는 여전히 모듈 컨트롤러 재정의를 가지고 그 단지 일을 거부한다. 여기에 내가 무엇을 가지고 :

\ 응용 프로그램 \ 코드 \ 로컬 \ 회사 \ OnepageCheckout \ 등 \ config.xml의 응용 프로그램 \ 코드 \

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Company_OnepageCheckout> 
      <version>0.0.1</version> 
     </Company_OnepageCheckout> 
    </modules> 
    <frontend> 
     <routers> 
      <onepagecheckout> 
       <args> 
        <modules> 
         <company_onepagecheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</company_onepagecheckout> 
        </modules> 
       </args> 
      </onepagecheckout> 
     </routers> 
    </frontend> 
</config> 

\ 로컬 \ 회사 \ OnepageCheckout 컨트롤러 \ \ 인 IndexController .PHP

<?php 

require_once(Mage::getModuleDir('controllers','IWD_OnepageCheckout').DS.'IndexController.php'); 

class Company_OnepageCheckout_IndexController extends IWD_OnepageCheckout_IndexController 
{ 
    function indexAction() { 
     die('Hello world!'); 
    } 
} 

\ 응용 프로그램 \ 등 \ 모듈 \ Company_OnepageCheckout.xml

다른 질문에 제안 먼저 내 모듈을 볼 수 6,
<?xml version="1.0"?> 
<config> 
    <modules> 
     <Company_OnepageCheckout> 
      <active>true</active> 
      <codePool>local</codePool> 
      <depends> 
       <IWD_OnepageCheckout /> 
      </depends> 
     </Company_OnepageCheckout> 
    </modules> 
</config> 

이 모듈은이 게시물의 상단에 언급 한 바와 같이 \app\code\community\IWD\OnepageCheckout\[...]

에 위치한 모듈을 무시하기위한 것입니다, 나는 반사 클래스를 사용했습니다 커뮤니티 모듈 앞의 배열에서. 그러나 mysite.com/onepagecheckout을 방문하면 커뮤니티 모듈이 계속 표시되며 내 파일을 사용할 수 없습니다.

여기 내 직감은 내가 방금 누락 한 모듈 이름의 대문자와 관련이있을 수 있다는 것입니다.

답변

2

그냥

<company_onepagecheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</company_onepagecheckout> 

그 다음 작동하지 않는 경우

<Company_OnepageCheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</Company_OnepageCheckout> 

에이

+0

이했던 일이지만, 그것은이다 내 생각에 / 방법이 구식입니다. (Magento EE 1.13.0.1을 실행 중입니다.) –

1

당신에게에

<global> 
     <!-- This rewrite rule could be added to the database instead --> 
     <rewrite> 
      <!-- This is an identifier for your rewrite that should be unique --> 
      <!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER --> 
      <mynamespace_mymodule_onepage_iwd> 
       <from><![CDATA[#^/onepagecheckout/index/#]]></from> 
       <!-- 
        - mymodule matches the router frontname below 
        - checkout_cart matches the path to your controller 

        Considering the router below, "/mymodule/checkout_car/" will be 
        "translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?) 
       --> 
       <to>/comonepagecheckout/index/</to> 
      </mynamespace_mymodule_onepage_iwd> 
     </rewrite> 
    </global> 
<frontend> 
     <routers> 
      <comonepagecheckout> 
       <!-- should be set to "admin" when overloading admin stuff (?) --> 
       <use>standard</use> 
       <args> 
        <module>Company_OnepageCheckout</module> 
        <!-- This is used when "catching" the rewrite above --> 
        <frontName>comonepagecheckout</frontName> 
       </args> 
      </comonepagecheckout> 
     </routers> 
    </frontend> 

See more을 사용 변경 가장 좋은 방법은 디버깅 코드를 표준 라우터에 드롭하는 것입니다 (물론 일시적입니다).

#File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php 
protected function _validateControllerClassName($realModule, $controller) 
{ 
    $controllerFileName = $this->getControllerFileName($realModule, $controller); 
    if (!$this->validateControllerFileName($controllerFileName)) { 
     return false; 
    } 

    $controllerClassName = $this->getControllerClassName($realModule, $controller); 
    if (!$controllerClassName) { 
     return false; 
    } 

    // include controller file if needed 
    if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) { 
     return false; 
    } 

    return $controllerClassName; 
} 

각각 false를 반환 라우터가 구성된 컨트롤러를 고려하고 부적절한 이름을 기반으로 그것을 찾을 수있는하거나 파일을 포함하지 거부 인스턴스 등

+0

이것이 어디서 디버깅 할 수 있는지 알고있는 것이 좋지만 코드가이 함수에 도달 할 때까지 $ realModule은 이미 IWD_OnepageCheckout으로 설정되어 있습니다. 재정의하려고합니다. 그래서 실제로이 경우 문제를 해결하는 데 도움이되지 않았습니다. –

+0

@TylerV. 그렇다면 Magento에서 모듈을 볼 수 없으며 IDW 모듈을 검사하기 위해 모듈 목록에 추가됩니다. 'foreach ($ realmodule $ realModule) {'섹션에 팝업하여'$ modules' 안에 무엇이 있는지 살펴보십시오. –