Get all invoices in Magento

情到浓时终转凉″ 提交于 2019-11-29 05:22:33

You need to use :

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

For the explanation :

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

  • first, you choose the right method to access it : Mage::getModel for a model

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

Mage::getModel("sales/order_invoice")

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>
     [...]
  • 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")

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!