dongze5043
2014-10-08 14:19
浏览 113
已采纳

如何在Magento API之外获取Quote数据?

I am trying to write a script to process all the orders from my magento store. I am able to get Shipping,Billing address and customer's name but now I want the list of items they have bought which i think will be in "quote" object.

I am trying this 2 lines to get quote object but I am getting an empty array. Please tell me what's wrong with this code.

$salesCollection = Mage::getModel("sales/order")->getCollection()->addAttributeToFilter('state', array('eq' => Mage_Sales_Model_Order::STATE_PROCESSING));
foreach($salesCollection as $order)
{
   $quote_id = $order->getQuoteId();
   $quote = Mage::getModel('sales/quote')->load($quote_id);
   print_r($quote->getData());
}
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzhuoxie1244 2014-10-08 14:26
    已采纳

    No, they are not in "quote" object. You can get using this sample code -

    $order_id = 1234; //use your own order id 
    $order = Mage::getModel("sales/order")->load($order_id); 
    $ordered_items = $order->getAllItems();
    
    foreach($ordered_items as $item){     
        echo $item->getName();
    }
    

    Now using foreach loop on $ordered_items, you can get item data.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dty63504 2014-10-08 14:26

    To get order item you need order item and not quote

    $salesCollection = Mage::getModel("sales/order")->getCollection()
               ->addAttributeToFilter('state', array('eq' => Mage_Sales_Model_Order::STATE_PROCESSING));
    
    foreach($salesCollection as $order){
       $shipping = $order->getShippingAddress();
       .... 
       $items = $order->getAllVisibleItems();
       foreach($items as $item){
         echo $item->getProductId();
       }
    }
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题