我想在magento订购成功页面上获取产品图片,这里是代码
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
foreach ($order->getAllItems() as $item) {
//Need image code here
}
?>
是否有人知道如何在单页成功页面上获取产品图片
谢谢
答案 0 :(得分:0)
使用缩略图
检查此代码是否安静<?php
$model = Mage::getModel('sales/order') //getting product model
$_product = $model->load(Mage::getSingleton('checkout/session')->getLastRealOrderId()); //getting product object for particular product id
echo $_product->getImageUrl(); //product's image url
echo $_product->getSmallImageUrl(); //product's small image url
echo $_product->getThumbnailUrl(); //product's thumbnail image url
?>
答案 1 :(得分:0)
$orderIcrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIcrementId);
$orderItems = $order->getAllItems();
foreach($orderItems as $orderItem):
$_product = Mage::getModel('catalog/product')->load($orderItem->getProductId());
$product_small_image_path = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135);
$product_thumbnail_path = Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(56);
endforeach;