how to call resource model methods in Block.php files or phtml files
-
16-10-2019 - |
سؤال
I could not call resource model function display records in block/dotnet.php
المحلول
Instead of Mage::getModel('dotnet/dotnet')->displayrecods()
use:
Mage::getResourceModel('dotnet/dotnetmodel')->displayrecods()
Or better yet in your model (dotnet/dotnet
) create a method named displayrecords
so you will be able to use your original code. That method can look like this:
public function displayrecods(){
return $this->_getResource()->displayrecods();
}
So this method will act like a wrapper for the method in the resource model.
[EDIT]
I think the problem is with your resource model declaration in config.xml
<dotnet_resource>
<class>Departmen_DotNet_Model</class>
...
Should be
<dotnet_resource>
<class>Departmen_DotNet_Model_Resource</class>
...
Next time post code, not screenshots of it
لا تنتمي إلى magento.stackexchange