Domanda

Ho creato tipo EAV personalizzato:

/* @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

Ho creato /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')
        );
    }
}

Vorrei ottenere collezione per tipo "av_photo_type" ora. Devo creare file di risorse per ottenere la raccolta ma non ho le tabelle personalizzate. Magento EAV modulo non ha risorse modello per la tabella eav_entity. Come arrivare raccolta eav_entity allora?

È stato utile?

Soluzione

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

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

L'articolo è davvero lunga ...

Se esistono le tabelle, è possibile utilizzare una raccolta estesa da collezione EAV

class Magentotutorial_Complexworld_Model_Resource_Eavblogpost_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
    protected function _construct()
    {
        $this->_init('complexworld/eavblogpost');
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top