カスタムタイプごとにEAV_ENTITYからエンティティのコレクションを入手するにはどうすればよいですか?
-
16-10-2019 - |
質問
カスタムEAVタイプを作成しました:
/* @var $installer Mage_Eav_Model_Entity_Setup */
$installer = $this;
$installer->startSetup();
$installer->addEntityType('av_photo_type', array(
'entity_model' => 'av_photo/eav_photo'
));
$installer->addAttribute('av_photo_type', 'name', array(
'label' => 'Type Name'
));
$installer->addAttribute('av_photo_type', 'code', array(
'label' => 'Unique Code',
'unique' => 1,
'note' => 'For internal using'
));
$installer->addAttribute('av_photo_type', 'order', array(
'label' => 'Order'
));
$installer->addAttribute('av_photo_type', 'active', array(
'label' => 'Active',
'type' => 'int',
'input' => 'boolean',
));
ファイル/model/eav/photo.phpを作成しました:
class Company_Photo_Model_Eav_Photo extends Mage_Eav_Model_Entity
{
public function __construct()
{
$resource = Mage::getSingleton('core/resource');
$this->setType('av_photo_type')->setConnection(
$resource->getConnection('sales_read'),
$resource->getConnection('sales_write')
);
}
}
今すぐ「av_photo_type」と入力してコレクションを入手したいと思います。コレクションを取得するにはリソースファイルを作成する必要がありますが、カスタムテーブルはありません。 Magento EAVモジュールには、EAV_ENTITYテーブルのリソースモデルがありません。それでは、EAV_ENTITYコレクションを入手する方法は?
解決
$installer->createEntityTables(
$this->getTable('complexworld/eavblogpost')
);
記事は本当に長いです...
テーブルが存在する場合は、EAVコレクションから拡張されたコレクションを使用できます
class Magentotutorial_Complexworld_Model_Resource_Eavblogpost_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
protected function _construct()
{
$this->_init('complexworld/eavblogpost');
}
}
所属していません magento.stackexchange