Magento-在phtml上显示订单注释


Magento - show order comments on a phtml

我为magento买了一个POS。我的magento正在magento 1.8.1 CE上运行。

POS通过phtml生成收据。然后它将被打印出来。(在80毫米收据打印机上)

但现在我想将订单注释添加到phtml 中

订单的基础已经加载到phtml:

$info_order = Mage::getSingleton('adminhtml/session')->getInfoOrder();
$entity_id = $info_order['entity_id'];
$order_id = Mage::getSingleton('adminhtml/session')->getOrderViewDetail();
$data = Mage::getModel('sales/order')->load($order_id);

但是我无法加载评论。

已经尝试过(在这里找到的许多其他代码中):

$ordercomment = $data->getData('comment');

在正文中的phtml

<?php echo $ordercomment ?>

但这行不通。我正在尝试的订单有订单注释。谁能帮我?

更新日期:2014年11月9日下午16:46(W-欧洲时间)我尝试了jQuery愤怒的小鸟的解决方案:

<?php $orders = Mage::getModel('sales/order')
    ->getCollection()
    ->addFieldToFilter('status',array('pending','processing'));
foreach ($orders as $order) {
    $orderComments = $order->getAllStatusHistory();
    foreach ($orderComments as $comment) {
        $body = $comment->getData('comment');
        echo $body;
    }
}

并尝试使用调用它

<?php echo $orderComments ?>

我现在从所有待处理/正在处理的订单中获取所有交易数据。但此订单已处于发货状态。我只想要客户添加到订单中的评论。不是交易历史记录。

我错过了什么?

使用以下方法

$orders = Mage::getModel('sales/order')
    ->getCollection()
    ->addFieldToFilter('status',array('pending','processing'));
foreach ($orders as $order) {
    $orderComments = $order->getAllStatusHistory();
    foreach ($orderComments as $comment) {
        $body = $comment->getData('comment');
        echo $body;
    }
}