0

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

I could not call resource model function display records in block/dotnet.php

2
  • The class name Department_DotNet_Model_dotnetmodel should be Department_DotNet_Model_Dotnet. The class name Department_DotNet_Model_Resource_dotnetmodel should be Department_DotNet_Model_Resource_Dotnet. Capital letters matter here, it might not hurt on your local PC when you trying to run on a linux server it will break. Blocks do not have a method called _redirect, that section of code should be called from a controller instead. It is bad practice to use any resource model from a block, keep that stuff to the regular model only. – clockworkgeek Oct 7 '13 at 10:57
  • @clockworkgeek thanks for suggestion, I will follow the same – prasad maganti Oct 16 '13 at 14:24
3

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

11
  • thanks for reply marius, either of the options are not helpful – prasad maganti Oct 7 '13 at 7:14
  • @prasadmaganti. Actually they are (or will be after you fix the error), but I've re-read the error message, more careful this time. Can you post your config.xml file in the question. I see that actually Mage::getModel('dotnet/dotnet') returns null. Also does the file Department_DotNet_Model_DotNet exist? – Marius Oct 7 '13 at 7:18
  • @prasadmaganti. I've also edited my answer. Try again with the first option. – Marius Oct 7 '13 at 7:19
  • i could not call model/resource function and model based function in my block/.php or phtml file. please help me. i have struck on this – prasad maganti Oct 7 '13 at 7:21
  • 1
    @prasadmaganti.Then post your entire module in the question. So we can reproduce it. – Marius Oct 7 '13 at 7:24

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.