我正在尝试在magento订单页面上创建一个打印操作(printscreen:sbx.mujjo.com/media/images/action.png)。现在'打印标签'是html页面的网址。我试图让它打开一个.pdf(就像'打印发票'。但我找不到合适的代码。
创建网址的代码:
class AquiveMedia_Orderlabel_Model_Observer {
public function add_action($observer) {
$block = $observer->getEvent()->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction) {
if ($block->getParentBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
$block->addItem('print_labels', array(
'label' => Mage::helper('sales')->__('Print Labels'),
'url' => $block->getUrl('orderlabel/adminhtml_orderlabel/massprint')
)
);
}
}
}
}
答案 0 :(得分:0)
由于链接已经存在,只需使用自己的URL。以下是如何覆盖。
在模块的config.xml
文件中
<config>
...
<admin>
<routers>
<adminhtml>
<args>
<modules>
<aquivemedia_orderlabel before="Mage_Adminhtml">
AquiveMedia_Orderlabel_Adminhtml
</aquivemedia_orderlabel>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
现在你可以制作一个控制器,它将首先被调用
app/code/local/AquiveMedia/Orderlabel/controllers/Adminhtml/Sales/Order/InvoiceController.php
:
class AquiveMedia_Orderlabel_Adminhtml_Sales_Order_InvoiceController
extends Mage_Adminhtml_Controller_Action
{
public function printAction()
{
// this is called instead of the path "index.php/admin/sales_order_invoice/print"
}
}