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

我无法在block/dotnet.php中调用资源模型函数显示记录

有帮助吗?

解决方案

代替 Mage::getModel('dotnet/dotnet')->displayrecods() 利用:

Mage::getResourceModel('dotnet/dotnetmodel')->displayrecods()

或在您的模型中更好(dotnet/dotnet)创建一个名称的方法 displayrecords 因此,您将能够使用原始代码。该方法看起来像这样:

public function displayrecods(){
    return $this->_getResource()->displayrecods();
}

因此,此方法将像资源模型中的方法一样起作用。
编辑
我认为问题在于您的资源模型声明 config.xml

<dotnet_resource>
    <class>Departmen_DotNet_Model</class>
...

应该

<dotnet_resource>
    <class>Departmen_DotNet_Model_Resource</class>
...

下次邮政编码,而不是屏幕截图

许可以下: CC-BY-SA归因
scroll top