Magento在success.phtml上按订单ID访问sku

时间:2011-04-19 09:37:40

标签: php magento

在success.phtml模板上,我需要从已完成的订单中列出sku。如何迭代订单并检索这些值?

1 个答案:

答案 0 :(得分:3)

你应该扩展Mage_Checkout_Block_Success

并添加类似于此的方法:

 public function getOrder()
    {
        return Mage::getModel('sales/order')->load($this->getLastOrderId());
    }

并在您的success.phtml模板中:

$order = $this->getOrder(); 
foreach($order->getAllItems() as $item){
//$item is your product object and you can do what you want with this;
}