简体   繁体   English

Magento通过success.phtml上的订单ID访问SKU

[英]Magento Accessing sku's by order id on success.phtml

On the success.phtml template, I need to list the sku's from the completed order. 在success.phtml模板上,我需要列出已完成订单中的sku。 How can I iterate through the order and retrieve these values? 如何遍历订单并检索这些值?

you should extend Mage_Checkout_Block_Success 您应该扩展Mage_Checkout_Block_Success

and add the method similar to this: 并添加与此类似的方法:

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

and in your success.phtml template: 并在您的success.phtml模板中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM