For example,I have created a custom module UserProfile .
i.e
magento\app\code\local\CustomerProfile\Userprofile
and my model in Userprofile is
magento\app\code\local\CustomerProfile\Userprofile\Model\Customersettings.php
Customersettings.php is as following:
class CustomerProfile_Userprofile_Model_Customersettings extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init("userprofile/customersettings");
}
function getmessage()
{
echo "Hello From Custom model method:";
}
}
I can call the method of custom model anywhere as following:
Mage::getModel('modulename/modelname')->modelmethod();
i.e.
Mage::getModel('userprofile/customersettings')->getmessage();
i.e
magento\app\code\local\CustomerProfile\Userprofile
and my model in Userprofile is
magento\app\code\local\CustomerProfile\Userprofile\Model\Customersettings.php
Customersettings.php is as following:
class CustomerProfile_Userprofile_Model_Customersettings extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init("userprofile/customersettings");
}
function getmessage()
{
echo "Hello From Custom model method:";
}
}
I can call the method of custom model anywhere as following:
Mage::getModel('modulename/modelname')->modelmethod();
i.e.
Mage::getModel('userprofile/customersettings')->getmessage();
Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
ReplyDeletemagento development company in bangalore