2012-03-05 17 views
0

私はカスタム価格の商品をいくつか持っています。選択されたオプションに応じて、製品に料金を追加する式が適用されるため、価格は決して同じではありません。私が追加した場合Magento:注文価格で商品を並べ替え、価格は常に0

$order = Mage::registry('current_order'); 
$items = $order->getItemsCollection(); 
foreach ($items as $item) { 
    try { 
     $cart->addOrderItem($item); 
     ... 

:私が持っている問題は、並べ替えたときに、並べ替え、製品の価格は常に0

販売/コントローラ/ OrderControllerであり、機能の追加注文で、これがあることですこれらの行は、私はカスタム価格を取得することができますが、商品を編集する方法を見つけることができないので、価格は注文に追加されます。

$options = $item->getProductOptions(); 
$options = $options['info_buyRequest']; 
$customPrice = $options['custom_price']; 

私は成功せず、($ cart-> addOrderItem($アイテム)の前に、ループ内で)試してみました何があります。

$item->setSpecialPrice($customPrice); 
$item->setCustomPrice($customPrice); 
$item->setOriginalPrice($customPrice); 
$item->setBaseOriginalPrice($customPrice); 
$item->setBaseCost($customPrice); 
$item->setBaseRowInvoiced($customPrice); 
$item->setRowInvoiced($customPrice); 
$item->save(); 

助けが必要ですか?

答えて

3

いくつかの可能性があります。私はcheckout_cart_product_add_afterイベントのためにイベントオブザーバーを試みます。

// observer method: 
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer) 
{ 
    $action = Mage::app()->getFrontController()->getAction(); 
    if ($action->getFullActionName() == 'sales_order_reorder') 
    { 
     $buyInfo = $observer->getQuoteItem()->getBuyRequest(); 
     if ($customPrice = $buyInfo->getCustomPrice()) 
     { 
      $observer->getQuoteItem()->setCustomPrice($customPrice) 
       ->setOriginalCustomPrice($customPrice); 
     } 
    } 
} 
+0

ありがとうございます!私はこれを試してみるでしょうが、あなたの$ itemはどこから来ますか? –

+0

Ups、申し訳ありません、それは '$ observer-> getQuoteItem()'になります。私はサンプルコードを更新しました。 – Vinai

+2

ええ、私はあなたの答えの前にそれを理解しました、そして、それはうまくいきます。どうもありがとうございます! –

関連する問題