0

I am learning magento orm.I know get data using orm.but my problam is how i exacly know which model responcible for give specipic data. as example I know if I want get product name I use $collection = Mage::getModel('catalog/product') but is there any documentation like this model responsible for give that data. as example if i want to get cart data what model I used etc.

4

Lets take a look at Mage::getModel('catalog/product').With this call you will get instance of Mage_Catalog_Model_Product class, defined in app/code/core/Mage/Catalog/Model/Product.php.

First part of catalog/product, catalog, comes from modules configuration, and is usually the same as name of module folder. In app/code/core/Mage/Catalog/etc/config.xml you can see this declaration:

         <models>
            <catalog>
                <class>Mage_Catalog_Model</class>
            </catalog>
            .........
         <models>

The second part of catalog/product, product, is our class defined under Model folder, Product.php

Magento is able to do that by using factory design pattern(in the same way you can get the instance of helpers and blocks). If you want to understand better how it works, take a look in app/Mage.php at getModel() function.

Now, the Magento entities are self explanatory. For example, if you want to use cart model just call it like that Mage::getModel('checkout/cart'). Here checkout is the module, and cart is the php class under Model folder. Just take a look in that model class and you will find the methods available.

Good luck !

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.