在magento签出成功页面上显示属性(制造商、尺寸、颜色)


Showing attribute ( Manufacture, Size, Color ) on magento checkout success page

实际上,我这样做是为了在magento结账成功页面上检索我的订单详细信息

<?php 
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id); 
$shipping_address_data = $order_details->getShippingAddress();
?>
             <tr> 
                <th><?php echo $this->__('Item Description') ?></th>
                <th><?php echo $this->__('Manufacture') ?></th>
                <th><?php echo $this->__('Color') ?></th>
                <th><?php echo $this->__('Size') ?></th>
                <th><?php echo $this->__('Qty') ?></th>
                <th><?php echo $this->__('Unit Price') ?></th>
            </tr>      
        <?php foreach($order_details->getAllVisibleItems() as $item): ?> 
            <tr>
                <td><?php echo $item->getName() ?></td>
                <td><?php echo $item->getManufacture() ?> </td>
                <td><?php echo $item->getSize() ?> </td>
                <td><?php echo $item->getColor() ?></td>
                <td><?php echo round($item->getQtyOrdered(), 0) ?></td>
                <td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
            </tr>
        <?php endforeach ?> 
        <?php echo "<br>" . $shipping_address_data['country_name']; ?>

除了尺寸、颜色、制造商和国家名称(未显示)外,一切正常

实际上,代码出了什么问题,有人有什么建议吗?

感谢

$项目不是give whole product dat a,它给出了roduct item是如何订购的,它生产了一些产品名称、数量等。

如果你想获得产品,那么你需要按项目加载产品id。

     $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku());
       echo $_product->getManufacture() ;
        echo  $_product->getSize(); //size optionid
        echo  $_product->getColor(); //color otion id
echo $_product->getAttributeText('color');
echo $_product->getAttributeText('size'); // size optionlabel

使用getAllItems而不是getAllVisibleItems

 <?php 
      foreach($order_details->getAllItems () as $item):
        echo "<pre>";print_r($item->getData());die;
      endforeach;
 ?> 

打印结果并检查是否获得属性值