0

有没有办法通过设置文件和资源文件使自定义 magento 产品属性可过滤?

我可以创建属性,我什至可以设置它进入的组,但无需手动进入管理员并调整属性上的可过滤选项,我无法将其设置为可过滤(尤其是可过滤 - 我我试过 w/true/false 和 0,1,2)。我已经尝试调整每个有意义的选项。

IE:

app/code/local/Company/Module/Model/Resource/Eav/Mysql4/Setup.php
public function getDefaultEntities()
{
    return array(
            'catalog_product' => array(
                'entity_model'      => 'catalog/product',
                'attribute_model'   => 'catalog/resource_eav_attribute',
                'table'             => 'catalog/product',
                'additional_attribute_table' => 'catalog/eav_attribute',
                'entity_attribute_collection' => 'catalog/product_attribute
                'attributes' => array(
                    'attribute_name' => array(
                        'group'                      => 'Attribute Set Group',
                        'type'                       => 'int',
                        'backend'                    => '',
                        'frontend'                   => '',
                        'label'                      => 'Attribute Label',
                        'input'                      => 'select',
                        'class'                      => '',
                        'source'                     => 'eav/entity_attribu
                        'global'                     => Mage_Catalog_Model_
                        'visible'                    => true,
                        'required'                   => false,
                        'user_defined'               => true,
                        'default'                    => false,
                        'searchable'                 => true,
                        'filterable'                 => 1,
                        'comparable'                 => false,
                        'visible_on_front'           => true,
                        'visible_in_advanced_search' => true,
                        'used_in_product_listing'    => true,
                        'used_for_sort_by'           => true,
                        'unique'                     => false,
                    ),
                ),
            ),
        );
}


app/code/local/Company/Module/Model/sql/module_setup/mysql4-install-0.1.0.php
$this->installEntities();
4

1 回答 1

2

您可以通过以下方式添加属性:

module_name\sql\machinesearch_setup

在您的模块中创建一个这样的 SQL 设置文件。

<?php
    $installer = $this;
    $data= array (
        'attribute_set' =>  'Default',
        'global'    =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'label'     => 'Year',
        'input'     => 'multiselect',
        'type'      => 'text',
        'default_value_text' => 'varchar',
        'unique'    => false,
        'required'  => false,
        'visible'   => true,
        'searchable'=> true,
        'visible_in_advanced_search'    => true,
        'html_allowed_on_front'         => true,
        'comparable'   => false,  
        'backend_type'  => 'varchar',
        'backend'   => 'eav/entity_attribute_backend_array',
        'group'     => 'General',
        'user_defined'  => true,
       );

       $installer->addAttribute('catalog_product','mmy_year',$data);


       $data= array 
        (  
        'attribute_set' =>  'Default',
        'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'label' => 'Make',
        'input' => 'multiselect',
        'type'  => 'text',
        'default_value_text'  => 'varchar',
        'unique'=> false,
        'required'=> false,
        'visible' => true,
        'searchable'=> true,
        'visible_in_advanced_search'=> true,
        'html_allowed_on_front'  => true,
        'comparable'=> false,
        'backend_type'  => 'varchar',
        'backend'=> 'eav/entity_attribute_backend_array',
        'group'  => 'General',
        'user_defined'=> true,
        );    
        $installer->addAttribute('catalog_product','mmy_make',$data);
    $data= array (
          'attribute_set'               =>  'Default',
          'global'                          =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
          'label'                           => 'Model',
          'input'                           => 'multiselect',
          'type'                            => 'text',
          'default_value_text'            => 'varchar',
          'unique'                          => false,
          'required'                    => false,
          'visible'                     => true,
          'searchable'                  => true,
          'visible_in_advanced_search'  => true,
          'html_allowed_on_front'       => true,
          'comparable'                  => false,
          'backend_type'                  => 'varchar',
          'backend'                     => 'eav/entity_attribute_backend_array',
          'group'                           => 'General',
          'user_defined'                    => true,
          );

  $installer->addAttribute('catalog_product','mmy_model',$data);
  $installer->endSetup();
?>
于 2012-08-20T09:39:51.460 回答