- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
快速提问(阅读时请记住这一点):
为什么会产生此错误(解释)以及如何编辑 pdfRmaAction()
正常工作(Mass Action Printing)???
**在 Magento 中工作 v.1.10.1.0
与 v.1.5.1.0
相同
冗长的解释:
我已经下载了这个扩展程序 ( http://www.magentocommerce.com/magento-connect/admin-order-printing-extension.html ) 来为每个 订单添加一个按钮,这样当您进入订单时,您就有一个额外的按钮来打印 RMA(从此自定义扩展模型 pdf - 变成了基于发票的自定义 RMA 表格)
效果很好。但是,我想向其中添加 Mass Action 打印,以便您可以检查一些订单并从下拉列表中选择 Print RMA 并打印这些订单的表格。
在扩展中 config.xml
文件 (app/code/local/Nastnet/OrderPrint/etc/),在 <config>
内标签是这样的:
<modules>
<Nastnet_OrderPrint>
<version>0.1.3</version>
</Nastnet_OrderPrint>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>Nastnet_OrderPrint_Block_Sales_Order_Grid</sales_order_grid> <!-- ADDED THIS FOR MASS ACTION PRINTING -->
<sales_order_view>Nastnet_OrderPrint_Block_Sales_Order_View</sales_order_view>
</rewrite>
</adminhtml>
</blocks>
<rewrite>
<Nastnet_OrderPrint_OrderController>
<from><![CDATA[#/\w+/sales_order/print/#]]></from>
<to>/orderprint/order/print/</to>
</Nastnet_OrderPrint_OrderController>
</rewrite>
<models>
<Nastnet_OrderPrint>
<class>Nastnet_OrderPrint_Model</class>
</Nastnet_OrderPrint>
</models>
<pdf>
<order>
<default>Nastnet_OrderPrint/order_pdf_items_order_default</default>
<grouped>Nastnet_OrderPrint/order_pdf_items_order_grouped</grouped>
</order>
</pdf>
</global>
<admin>
<routers>
<Nastnet_OrderPrint>
<use>admin</use>
<args>
<module>Nastnet_OrderPrint</module>
<!-- This is used when "catching" the rewrite above -->
<frontName>orderprint</frontName>
</args>
</Nastnet_OrderPrint>
</routers>
</admin>
在 (app/code/local/Nastnet/OrderPrint/Block/Sales/Order/) 中 Grid.php
这是:
class Nastnet_OrderPrint_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
protected function _prepareMassaction()
{
parent::_prepareMassaction();
// Append new mass action option
$this->getMassactionBlock()->addItem('rmaprint',
array('label' => $this->__('Print RMA'),
'url' => $this->getUrl('orderprint/order/pdfRma')));
}
}
这会导致将“打印 RMA”插入到“销售”>“订单” GridView 屏幕上的下拉菜单中的预期结果。
在OrderController.php
文件 (app/code/local/Nastnet/OrderPrint/controllers/) 我添加了这个 [从 pdfinvoicesAction()
复制和编辑]在 app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php 中:
public function pdfRmaAction(){
$orderIds = $this->getRequest()->getPost('order_ids');
//print_r($orderIds);
$flag = false;
if (!empty($orderIds)) {
foreach ($orderIds as $orderId) {
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
->setOrderFilter($orderId)
->load();
//print get_class($invoices);
//print_r($invoices->getSize());
if ($invoices->getSize() > 0) {
$flag = true;
if (!isset($pdf)){
$pdf = Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
} else {
$pages = Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
$pdf->pages = array_merge ($pdf->pages, $pages->pages);
}
}
}
if ($flag) {
return $this->_prepareDownloadResponse(
'rma'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
'application/pdf'
);
} else {
$this->_getSession()->addError($this->__('There are no printable documents related to selected orders.'));
$this->_redirect('*/*/');
}
}
$this->_redirect('*/*/');
}
这会导致实际的pdf出现错误...
Fatal error: Call to a member function getStore() on a non-object in /chroot/home/artizara/dev.artizara.com/html/app/code/local/Nastnet/OrderPrint/Model/Order/Pdf/Order.php on line 60
但是,如果您进入订单并按下打印 RMA 按钮(而不是尝试通过 Mass Action 打印它),那么它很好!
我长篇大论的解释导致了这一点: 为什么会产生这个错误,我该如何编辑 pdfRmaAction()
正常工作(Mass Action Printing)???
最佳答案
问题是您使用的 $order
变量未设置为函数 getPdf
的参数。您应该可以使用此功能:
public function pdfRmaAction() {
$orderIds = $this->getRequest()->getPost('order_ids');
$flag = false;
if (!empty($orderIds)) {
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
$flag = true;
$order->setOrder($order);
if (!isset($pdf)) {
$pdf = Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
} else {
$pages = Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
$pdf->pages = array_merge($pdf->pages, $pages->pages);
}
}
if ($flag) {
return $this->_prepareDownloadResponse(
'rma'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
'application/pdf'
);
} else {
$this->_getSession()->addError($this->__('There are no printable documents related to selected orders.'));
$this->_redirect('*/*/');
}
}
$this->_redirect('*/*/');
}
关于php - Magento - 添加自定义批量操作 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9981315/
Magento 主题和 Magento 皮肤有什么区别?它们和 Magento 模块之间有什么关系? 最佳答案 主题是创建视觉体验的布局、模板、区域设置和/或外观文件的任意组合... 主题由以下任意或
我想在 Magento 之外获得购物车 Block。这是我的代码。 getLocale()->getLocaleCode(); //Solution Mage::getSingleto
我是 Magento 新手,使用 CE 1.7.0.2 开发了一个网站。现在可以上线了,但我遇到了页面加载缓慢的问题。 我的网站产品主页、列表和详细信息页面最初需要 10-13 秒的时间来加载页面,但
我在 magento 网站上工作。我有 4 个类别,其中两个使用其他主题(不是我的特定 magento 主题)。我如何配置我的主题以从我的默认主题而不是基本主题中获取丢失的文件。 谢谢 最佳答案 通常
我遇到了我的 magento 项目的要求,因此我需要为特定客户群的购买提供特别折扣。此折扣必须显示在客户帐户中,如果他们属于该特定组,并且当用户要使用该特定折扣时,必须根据该折扣优惠对该商品的价格进行
我在 Magento 主题开发中找到的大量教程建议从使用空白作为制作您自己的自定义主题的指南开始。很多这些文章已经很旧了,截至当前版本(1.7),情况仍然如此吗? 附言- 除了 Magento 的 o
似乎这应该是一个可以找到的问题,但我找不到它。 magento 数据库中存储的类别 NAME 在哪里?我可以看到 catalog_category_entity有 key ID,然后还有其他 EAV
我知道 magento 会根据需要调整原始产品图像的大小并以不同的大小对其进行多次缓存。 这些 chached 图像存储在哪里(路径)? 当您从缓存管理中刷新图像缓存时,它们会被删除吗? 如果我要手动
我在我的 magento 网上商店中使用这个扩展 http://www.manadev.com/seo-layered-navigation-plus (分层导航) 此扩展适用于简单的产品。 但就我而
我在 Magento 的一家商店下拥有某些产品的批发属性。我想设置它,以便这些特定属性仅出现在产品页面上,如果客户已登录并且他们在批发客户组中。 这可能吗? 最佳答案 像这样的事情应该可以工作,尽管我
和有什么区别和 在 Magento 中? 我将创建一个新模块,我必须决定在这两个事件中的哪一个事件中挂起我的观察者。 最佳答案 类别(和所有其他对象)保存在事务中。事件catalog_categor
好吧,这是一个似乎很容易解决的问题,但它让我望而却步...... 我的 Magento Web 上有一些类别,每个类别都有一些产品。我希望它们显示为 4 列计数,但它始终显示为 3 列计数,如下所示:
我已经在我的网站上添加了一些成员(member)跟踪代码。为了使跟踪工作正常进行,我需要向关联公司提供确认付款的网址。 我正在使用Magento,我不确定该版本,但几年内未对其进行更新。我需要知道订单
我们的网站遇到了问题。 系统 > 配置屏幕仅显示菜单、侧面菜单和页脚。当我们点击侧边菜单选项时,屏幕仍然黑屏,相关信息也没有出现。请看 this link .这就是出现的情况。当我们点击任何侧面菜单选
我想只使用一个 csv 文件来翻译前端 Magento 商店。所以我这样做了: 我创建了一个名为 Translator 的自定义模块。在其 config.xml 中,我放置了以下几行: ....
我添加了自定义订单状态选项。 有谁知道我如何通过API将其设置为自定义值? 最佳答案 感谢Diglin为我指出的正确位置。只是为了正确地给出答案: 您可以使用addComment方法来执行此操作,该方
目前,Magento 处理大规模操作的方式存在问题。无论分页如何,它都会返回一些 JS,其中包含当前集合和过滤器的每个 db id。这是为了支持网格标题中的“全选”与“全选可见”选项。当您的记录数量较
如何收集具有此角色的所有角色(系统->权限->角色)和用户? 谢谢。 最佳答案 获得所有角色 $roles = Mage::getModel('admin/roles')->getCol
如果能在我网站的各种应用程序之间进行通用登录,那将是一种巨大的用户体验。现在,我有一个 Magento 店面和一个 IPS 板社区。我正在尝试将它们集成到我的用户的一个通用登录中。 IPS 板提供多种
我正在为 Magento 社区 1.4.2 版中的时尚客户开发一个网站,作为该项目的一部分,我需要一些定制的主页促销块来展示特定产品或产品类别。为此,我想我会编写自己的小部件,并且除了如何处理图像外,
我是一名优秀的程序员,十分优秀!