Magento quick getResourceModel question

What class (if any) is called with this line of code?

Mage::getResourceModel('sales/order_invoice_collection') 

In fact, I'm trying to figure out which database this resource model is accessing, and how I can fine-tune it. Thanks!

+6
source share
3 answers

The class you are looking for is:

 Mage_Sales_Model_Mysql4_Order_Invoice_Collection 

located in app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php .

If you look at the configuration of the app/code/core/Mage/Sales/etc/config.xml sales module, you can see the table name in the definition of resource models:

 <config> <global> <models> <sales_mysql4> <entities> ... <invoice><table>sales_flat_invoice</table></invoice> ... </entities> </sales_mysql4> </models> </global> </config> 

To learn more about how Magento interacts with the database, you should read about models, resource models, and collections:

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics

+14
source

Try this to get the class resulting from the statement:

 $obj = Mage::getResourceModel('sales/order_invoice_collection'); print get_class($obj); 
+5
source

In this case, it loads

 code/Core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php 

which is the class name:

 Mage_Sales_Model_Mysql4_Order_Invoice_Collection 

This can be determined by looking at the config.xml file:

 code/Core/Mage/Sales/etc/config.xml. 

In it, under the model tag, is the sales tag, which you know from the "sales" before the slash in the line. There he defines the resource model as sales_mysql4. So if you call:

 Mage::getResourceModel('module/everything_else') 

the downloaded file will be:

 Module/Model/{contents of resourceModel tag}/Everything/Else.php 

Hope this helps.

+4
source

Source: https://habr.com/ru/post/894128/


All Articles