2011-09-01 2 views

답변

9

당신은 checkout_cart_product_add_after을 듣고 관찰자 클래스를 사용하고 견적 항목에 대해 사용자 정의 가격을 설정하는 제품의 "슈퍼 모드"를 사용할 수 있습니다. 당신의 /app/code/local/{namespace}/{yourmodule}/etc/config.xml에서

: 다음

<config> 
    ... 
    <frontend> 
     ... 
     <events> 
      <checkout_cart_product_add_after> 
       <observers> 
        <unique_event_name> 
         <class>{{modulename}}/observer</class> 
         <method>modifyPrice</method> 
        </unique_event_name> 
       </observers> 
      </checkout_cart_product_add_after> 
     </events> 
     ... 
    </frontend> 
    ... 
</config> 

그리고/응용 프로그램/코드에서 옵저버 클래스를 생성/지역/{네임 스페이스 }/{yourmodule} /Model/Observer.php 내가 관찰자를 사용하여 카트에 사용자 정의 가격을 설정 추가하면

<?php 
    class <namespace>_<modulename>_Model_Observer 
    { 
     public function modifyPrice(Varien_Event_Observer $obs) 
     { 
      // Get the quote item 
      $item = $obs->getQuoteItem(); 
      // Ensure we have the parent item, if it has one 
      $item = ($item->getParentItem() ? $item->getParentItem() : $item); 
      // Load the custom price 
      $price = $this->_getPriceByItem($item); 
      // Set the custom price 
      $item->setCustomPrice($price); 
      $item->setOriginalCustomPrice($price); 
      // Enable super mode on the product. 
      $item->getProduct()->setIsSuperMode(true); 
     } 

     protected function _getPriceByItem(Mage_Sales_Model_Quote_Item $item) 
     { 
      $price; 

      //use $item to determine your custom price. 

      return $price; 
     } 

    } 
+0

, 나는이 품목 수량을 곱한 주문 이메일 템플릿의 단가를 얻고있다. app \ design \ frontend \ default \ rfg \ template \ email \ order \ items \ order \ default.phtml formatPrice ($ _ item-> getRowTotal())을 수정하는 방법은 무엇입니까? > – Muk

+0

누구나'setIsSuperMode'를'$ item-> getProduct() -> setIsSuperMode (true); 라인에서 설명 할 수 있습니까? 그것은 무엇을합니까? – mkutyba

+2

다음은 슈퍼 모드에 대한 설명입니다. "제한없는 인용 부호로 작업하는 것을 의미하는 슈퍼 모드 플래그를 의미합니다" 예 : 슈퍼 모드가 true로 설정된 경우 magneto는 제품이 카탈로그에 표시되는지 확인하지 않습니다 – Nidheesh

관련 문제