2011-09-01 17 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> 

そして/アプリ/コードでObserverクラスを作成/ローカル/ {名前空間}/{} 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を修正するには <?php echo $ _order-> formatPrice($ _ item-> getRowTotal())? > – Muk

+0

'$ item-> getProduct() - > setIsSuperMode(true);'この行から 'setIsSuperMode'を説明することはできますか?それは何をするためのものか? – mkutyba

+2

スーパーモードのための解説は次のとおりです: "制限付きで引用符を使用することを意味するスーパーモードフラグの引用" 例:スーパーモードがtrueに設定されていると、magnetoはカタログに商品が表示されているかどうかをチェックしません – Nidheesh

関連する問題