0

みんなが元気になっていることを願っています。私はmagentoを初めて使用します。私はmagentoモジュールに取り組んでいます。Adminでグリッドを使用したいのですが、コレクションを使用する必要があります。私はいくつかのコレクションを作成しましたが、それらのいずれにも正常にアクセスできませんでした。どこが間違っているのか知りたい。私の問題をあなたと共有させてください。

私の設定ファイルチャンク

<models>

    <exporter>
        <class>World_Exporter_Model</class>
        <!-- 
        need to create our own resource, cant just
        use core_mysql4
        -->
        <resourceModel>exporter_mysql4</resourceModel>
    </exporter>   
<exporter_mysql4>
      <class>World_Exporter_Model_Mysql4</class>
      <entities>
             <exporter>
                        <table>profiles</table>
             </exporter>
      </entities>

</exporter_mysql4>
 </models>

私のモデル

class World_Exporter_Model_Mysql4_Profiles extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{

    $this->_init('exporter/profiles', 'profile_id');
}
}

そして私のコレクション

 class World_Exporter_Model_Mysql4_Profiles_Collection extends    Mage_Core_Model_Mysql4_Collection_Abstract
 {
public function _construct(){
    parent::_construct();
    $this->_init('exporter/profiles');
}
 }

あなたが私を助けたいのなら。私はとてもいっぱいです。

(回答を得た後に追加)...

    $model = Mage::getResourceModel('exporter/profiles');

    //  $model = Mage::getModel('exporter/profiles');           

    $collection = $model->getCollection();          

致命的なエラー:未定義のメソッドWorld_Exporter_Model_Mysql4_Profiles :: getCollection()の呼び出し

    //  $model = Mage::getResourceModel('exporter/profiles');

        $model = Mage::getModel('exporter/profiles');           

        $collection = $model->getCollection();

a:5:{i:0; s:47:エンティティ構成を取得できません:エクスポーター/プロファイル "; i:1; s:2542:

#0 \ app \ code \ core \ Mage \ Core \ Model \ Resource.php(272):Mage :: throwException('取得できません...')

#1 \ app \ code \ core \ Mage \ Core \ Model \ Resource \ Db \ Abstract.php(284):Mage_Core_Model_Resource-> getTableName('exporter / profile ...')

#2 \ app \ code \ core \ Mage \ Core \ Model \ Resource \ Db \ Abstract.php(247):Mage_Core_Model_Resource_Db_Abstract-> getTable('profiles')

しかし、私はデータベースにテーブル「プロファイル」を持っています

よろしくお願いします…</p>

4

2 に答える 2

4

それで、私はついに自分で答えを得ました、私は自分でそれをするのに十分な応答を得られなかったので、私の質問に対する唯一の応答者のおかげで、実際には彼の答えは私がこの問題を解決するのを助けます、それで彼にクレジットが行きます良い。

今の解決策

<exporter>
    <class>World_Exporter_Model</class>

    <resourceModel>exporter_mysql4</resourceModel>
</exporter>   
<exporter_mysql4>
  <class>World_Exporter_Model_Mysql4</class>
  <entities>
       <!-- This portion makes it stop working --> 
         <exporter>
                    <table>profiles</table>
         </exporter>
       <!-- This portion makes it stop working -->

       <!-- Replace the above highlighted portion with this portion -->
         <profiles>
                    <table>profiles</table>
         </profiles>

      <!-- Replace the above highlighted portion with this portion -->

  </entities>

 </exporter_mysql4>
</models>

したがって、上記のコード(xml)では、エクスポータータグをプロファイルに置き換えました

そしてコードを書く

class World_Exporter_Model_Profiles extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        // now profiles in this will catch the table name within profiles tags
        $this->_init('exporter/profiles');
    }
}

そしてそれは私のために働き始めました。

于 2012-09-06T13:17:23.367 に答える
1

モデルが欠落しているようです。config xmlを見ると、モデルと呼んでいるのはリソースモデルです。それでも実際のモデルを定義する必要があります。繰り返しますが、config xmlでは、このモデルはすでに宣言されています。<class>World_Exporter_Model</class>

基本クラスは次のようになります。

class World_Exporter_Model_Profiles extends Mage_Core_Model_Abstract
{
    public function _construct()
    {

        $this->_init('exporter/profiles');
    }
}

にある必要があります/app/code/local/World/Exporter/Model/Profiles.php

于 2012-08-16T21:25:46.313 に答える