我创建了自定义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',
));

我已经创建了file/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收集?

有帮助吗?

解决方案

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-part-7-Advanced-orm-entity-tity-attribute-value

$installer->createEntityTables(
    $this->getTable('complexworld/eavblogpost')
);

这篇文章真的很长...

如果存在表,您可以使用EAV Collection扩展的集合

class Magentotutorial_Complexworld_Model_Resource_Eavblogpost_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
    protected function _construct()
    {
        $this->_init('complexworld/eavblogpost');
    }
}
许可以下: CC-BY-SA归因
scroll top