block.phpファイルまたはphtmlファイルでリソースモデルメソッドを呼び出す方法

magento.stackexchange https://magento.stackexchange.com/questions/9014

  •  16-10-2019
  •  | 
  •  

質問

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

ブロック/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帰属
所属していません magento.stackexchange
scroll top