如何在magento销售订单历史记录中按订单ID打印订单

时间:2013-04-02 04:26:08

标签: magento magento-1.7 history

这是我在history.phtml页面中的代码

 <?php if($_orders->getSize()): ?>
 <?php $printurl = $this->getPrintUrl(); ?>
<table width="100%" cellspacing="2" cellpadding="3" border="0" align="center" class="order">
    <tbody>
        <tr bgcolor="#FF9800">
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Order #</b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Amount</b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Date of Order</b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>First Name </b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Last Name </b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Status</b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Processed</b></font>
            </td>
            <td align="left" style="width=100">
            <font size="2" face="Tahoma, Verdana" color="#FFFFFF"><b>Print</b></font>
            </td>
        </tr>
        <?php $_odd = ''; ?>
        <?php foreach ($_orders as $_order): ?>
        <tr>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana">
            <?php echo $_order->getRealOrderId() ?></font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana">
            <?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getFirstname()) : '&nbsp;' ?>
            </font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana">
            <?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getLastname()) : '&nbsp;' ?>
            </font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana"><?php echo $_order->getStatusLabel() ?></font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana"> 
            <?php //echo $_order->getStatus(); ?>
             </font>
            </td>
            <td valign="top" align="left" class="margin-top-1 margin-bottom-1" width:30%="">
            <font size="2" face="Tahoma, Verdana"><a class="blueColor" onclick="window.open('<?php echo $printurl;?>','printer_friendly','toolbar=0,location=0,status=0,menubar=1,scrollbars=1,resizable=1,width=640,height=390')">Print</a></font>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php else : ?>
<p>No order history found !.</p>
<?php endif ?>

$printurl类似于:

http://mysite.com/index.php/sales/order/print/order_id/104/

但现在$ printurl没有任何价值......

我该怎么做?

2 个答案:

答案 0 :(得分:0)

您可以使用而不是<?php $printurl = $this->getPrintUrl(); ?>这个

<?php $printurl = Mage::getUrl('sales/order/print', array('order_id',$_order->getId() )); ?>

foreach ($_orders as $_order)循环

答案 1 :(得分:0)

马吕斯是对的,但正确的版本是:

<?php $printurl = Mage::getUrl('sales/order/print', array('order_id' => $_order->getId() )); ?>