Magento EAV:用于什么'源'设置?

时间:2011-07-12 23:32:59

标签: magento entity-attribute-value

我很好奇这是用来做什么的?我为我添加了实体脚本的自定义属性定义了以下源模型,但我不知道如何使用source属性。也许我可以使用它的Form Widget?我添加的属性是exportStatus到customer eav。

<?php

class Company_Customer_Model_Customer_Attribute_Source_ExportStatus
    extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
    public function getAllOptions()
    {
        if (!$this->_options) {
            $this->_options = array(
                array(
                    'value' => '0',
                    'label' => 'Pending Export',
                ),
                array(
                    'value' => '1',
                    'label' => 'Exported to Mainframe',
                ),
                array(
                    'value' => '2',
                    'label' => 'Acknowledged by Mainframe',
                )
            );
        }
        return $this->_options;
    }
}

<?php

class Company_Customer_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{
    public function getDefaultEntities()
    {
        return array(
            'customer' => array(
                'entity_model'          =>'customer/customer',
                'attribute_model'       => 'customer/attribute',
                'table'                 => 'customer/entity',
                'additional_attribute_table' => 'customer/eav_attribute',
                'entity_attribute_collection' => 'customer/attribute_collection',
                'attributes' => array(
                    'export_status' => array(
                        //'group'             => 'Group/Tab',
                        'label'             => 'Customer Export Status',
                        'type'              => 'int',
                        'input'             => 'select',
                        'default'           => '0',
                        'class'             => '',
                        'backend'           => '',
                        'frontend'          => '',
                        'source'            => 'company_customer/customer_attribute_source_exportStatus',
                        'global'            => 2,  //global scope
                        'visible'           => true,
                        'required'          => false,
                        'user_defined'      => false,
                        'searchable'        => false,
                        'filterable'        => false,
                        'comparable'        => false,
                        'visible_on_front'  => false,
                        'visible_in_advanced_search' => false,
                        'unique'            => false
                    )


               )
           )

      );
    }
}

1 个答案:

答案 0 :(得分:1)