在 Magento 中获取所有发票 [英] Get all invoices in Magento

查看:16
本文介绍了在 Magento 中获取所有发票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取所有发票?

我知道要获得所有订单是:

I know that to get all the orders is:

 $orders = Mage::getModel(sales/order)->getCollection();

但是我似乎找不到发票的等价物(不是销售/发票).对不起,如果这是一个愚蠢的问题.

However I can't seem to find the equivalent with invoice (it's not sales/invoice). Sorry if it's a dumb question.

推荐答案

你需要使用:

$orders = Mage::getModel("sales/order_invoice")->getCollection();

解释:

当你想在 magento 中访问 i block/model/resource/helper/etc 时:

When you want to access i block/model/resource/helper/etc in magento :

  • 首先,您选择正确的方法来访问它:Mage::getModel 用于模型

第二,你必须告诉magento你想访问哪个"模块.你用参数字符串的第一部分来做到这一点:

second, you must tell magento "which" module you want to access. You do that with the first part of the parameter string :

Mage::getModel("销售/order_invoice")

Mage::getModel("sales/order_invoice")

此字符串指的是您要访问的类型或资源的 XML 节点.在您的情况下,要访问 Mage_Sales 模块的模型:查看 Mage_Sales 的 config.xml,您将看到要使用的节点(用于模型和资源模型):

This string refers to the XML node of the type or resource you want to access. In your case, for accessing a model of the Mage_Sales module : take a look at the Mage_Sales's config.xml, you'll see the node to use (used for models and resourceModels) :

[...]
<models>
    <sales><!-- <----- THIS NODE -->
        <class>Mage_Sales_Model</class>
         <resourceModel>sales_resource</resourceModel>
     </sales>
     [...]

  • 最后一部分,您需要添加对所需文件的完全访问权限,如果需要,还需要添加文件夹.在你的例子中,在 Mage_Sales 模块的模型文件夹中(上面的 xml 配置告诉我们这个文件夹是 Mage_Sales_Model),你会看到一个文件 Invoice.phpOrder 文件夹:那么你的路径是order_invoice",访问你的模型的完整命令是:
    • last part, you need to add the full access to the file you want, with folder if needed. In your case, in the Model folder of the Mage_Sales module (above xml config tells us that this folder is Mage_Sales_Model), you'll see a file Invoice.php in the Order folder : then you path is "order_invoice" and the full commande to access your model is :
    • Mage::getModel("sales/order_invoice")

      Mage::getModel("sales/order_invoice")

      这篇关于在 Magento 中获取所有发票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆