Magento快速获取ResourceModel问题

发布于 2024-11-27 10:27:37 字数 150 浏览 1 评论 0原文

这行代码调用了什么类(如果有)?

Mage::getResourceModel('sales/order_invoice_collection')

本质上,我试图找出使用此资源模型访问哪些数据库表以及如何调整它。谢谢!

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

Mage::getResourceModel('sales/order_invoice_collection')

Essentially I"m trying to figure out what database table is accessed with this resource model and how I can tweak that. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

度的依靠╰つ 2024-12-04 10:27:37

您正在寻找的类是这样的:

Mage_Sales_Model_Mysql4_Order_Invoice_Collection

位于app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php

如果您查看销售模块 app/code/core/Mage/Sales/etc/config.xml 的配置,您可以在资源模型的定义中看到表名称

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

:要了解有关 Magento 如何与数据库交互的更多信息,您应该阅读有关模型、资源模型和集合的内容:

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

The class you are looking for is this:

Mage_Sales_Model_Mysql4_Order_Invoice_Collection

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

If you take a look at the configuration for the sales module app/code/core/Mage/Sales/etc/config.xml, you can see the table name in the definition of the 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

倾城花音 2024-12-04 10:27:37

试试这个来获取由语句产生的类:

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

Try this to get the class resulting from a statement:

$obj = Mage::getResourceModel('sales/order_invoice_collection');
print get_class($obj);
森林迷了鹿 2024-12-04 10:27:37

在本例中,它正在加载

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

类名:

Mage_Sales_Model_Mysql4_Order_Invoice_Collection

这可以通过查看 config.xml 来确定:

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

在 models 标签下是 sales 标签,您可以从字符串中斜杠之前的“sales”得知。在那里,它将资源模型定义为 sales_mysql4。
因此,如果您调用:

Mage::getResourceModel('module/everything_else')

加载的文件将是:

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

希望有帮助。

In this instance it is loading

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

which is class name:

Mage_Sales_Model_Mysql4_Order_Invoice_Collection

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

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

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

Mage::getResourceModel('module/everything_else')

the file loaded will be:

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

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文