2010-12-17 4 views
5

이전에 많은 모듈을 작성했지만 어떤 이유로 배송 모듈이 기존의 Magneto 배송 방법보다 우선 적용되지 않습니다. 그게 허용됩니까? 내가 여기서 무엇을 놓치고 있니? 모듈 이름은 구성 영역의 고급 탭에 나타나므로로드되고 있지만 아무 것도 일어나지 않습니다. 어떤 힌트?배송 방법 무시 - 무엇이 누락 되었습니까?

코드

등/모듈/Ssi_Shipping.xml

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Ssi_Shipping> 
      <active>true</active> 
      <codepool>local</codepool> 
     </Ssi_Shipping> 
    </modules> 
</config> 

지역/SSI/배송/etc.xml

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Ssi_Shipping> 
      <version>0.1.0</version> 
     </Ssi_Shipping> 
    </modules> 
    <global> 
     <models> 
      <shipping> 
       <rewrite> 
        <carrier_tablerate>Ssi_Shipping_Model_Carrier_Tablerate</carrier_tablerate> 
       </rewrite> 

      </shipping> 
     </models> 
    </global> 
</config> 

지역/SSI/배송/모델/캐리어/Tablerate .php

<?php 
class Ssi_Shipping_Model_Carrier_Tablerate 
    extends Mage_Shipping_Model_Carrier_Tablerate { 

     public function isActive() 
     { 
      Mage::log("here! Ssi_Shipping_Model_Carrier_Tablerate"); 

      // check to see if it's disabled 
      if (parent::isActive() == false) 
       return false; 

      // check in the shopping cart 
      foreach(Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item){ 
       if ($item->getDeliveryFlag() == "test") 
        return true; 
      } 

      // if nothing is found then disable this option. 
      return false; 

     } 


    } 

답변

0

이 하나를 통해 약간의 작업 후, 나는 선적 컨트롤러를 대체 할 수있는 유일한 방법은 지역 코드 폴더에있는 파일 (및 디렉토리 구조)의 사본을 만들 것을 발견했다. 그럼 기본적으로 코드를 조정할 수 있습니다.

Magento가 이러한 배송 기능의 표준 재정의를 허용하지 않는 것 같지 않지만 해결 방법이없는 이유를 잘 모릅니다. (당신이 에서 Mage_Shipping_Model_Config을 보면

, 당신은 코드 마법사에 대한 매개 변수로 사용되는 것을 발견 할 것이다 ::을 getModel :

+0

강력하게 추천하지 않습니다. 이동 통신사를 무시할 수있는 확실한 방법이 있습니다. 제 답변을 참조하십시오. –

1

체 ck 먼저 모델이 전혀 무시되고있다. 이 시도 :

var_dump(get_class(Mage::getModel("shipping/carrier_tablerate"))); 
+0

내가 어디에 넣을 까? 페이지 어디에서나? – Chris

+0

프레임 워크를 초기화하는 파일을 보관하지만 나에게 "스크래치 보드"(거의 복제 된 index.php 파일)를 제공합니다. 빠르게하려면 템플리트에 넣을 수 있어야합니다. . 나중에 제거하는 것을 잊지 마십시오. –

12

는 방법이 있지만 명확하지 않다 및 운송 모듈의 자원을 검색하라고 요구)는 상점 구성에서 가져옵니다. 이 코드는 'shipping/carrier_tablerate'와 같은 표준 코드가 아니므로 평소처럼 재정의하는 데 도움이되지 않습니다.

이제이 코드의 내용을 먼저 찾아야합니다. 예를 들어 나는 matrixrate 캐리어를 무시하고 싶었다, 그래서 나는 그런 식으로 그것을 테스트 :

$carrierConfig = Mage::getStoreConfig('carriers/matrixrate') 
var_dump($carrierConfig['model']); 

예, 임시 페이지의 아무 곳이 코드를 넣을 수 있지만 그런 것들에 대한 별도의 파일을 가지고 유용하다 할 수

<global> 
    <models> 
     <matrixrate_shipping> 
      <rewrite> 
       <carrier_matrixrate>my_class_name</carrier_matrixrate> 
      </rewrite> 
     </matrixrate_shipping> 
    </models> 
: 명령 줄에서 실행 (마법사로 시작 : 응용 프로그램() 젠토를 초기화)

를 내 경우에는 코드 그래서 나는 그런 내 config.xml 파일을 변경했다 matrixrate_shipping/carrier_matrixrate이었다

대신

<global> 
    <models> 
     <matrixrate> 
      <rewrite> 
       <carrier_matrixrate>my_class_name</carrier_matrixrate> 
      </rewrite> 
     </matrixrate> 
    </models> 

행운을 빕니다!

+0

메이트,이 하나 주셔서 감사합니다, 그것은 내게 얼마 동안 두통을주고 있습니다 – Relja

0

오래되었지만 지난 번 같은 문제가있었습니다. 나는 freeshipping과 flatrate 배송 방법을 오버라이드하고 싶었고 fab의 답 이외에 다음 코드를 etc/config.xml에 추가해야했습니다. 필자의 경우 원래 값은 app/code/core/Mage/Shipping/etc/config.xml에 있습니다.

<?xml version="1.0"?> 
<config> 
    ... 
    <default> 
     <carriers> 
      <flatrate> 
       <model>your_module/shipping_carrier_flatrate</model> 
      </flatrate> 
      <freeshipping> 
       <model>your_module/shipping_carrier_freeshipping</model> 
      </freeshipping> 
     </carriers> 
    </default> 
</config> 

모델 값은 예제입니다. 올바른 경로로 바꿔야합니다.

+0

내 안에 무엇이 있는지 공유 할 수 있습니까? shipping_carrier_flatrate 클래스 –

0

누구든지이 문제에 직면하고 해결책을 찾았 으면 OP가 을 모듈 파일에 사용 했으므로 여기에 codePool (대문자 P가 있음)이 있어야합니다.

관련 문제