我添加了一个属性:

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'show_in_subview', array(
    'type'                       => 'varchar',
    'label'                      => 'Show in Subview',
    'input'                      => 'multiselect',
    'backend'                    => 'eav/entity_attribute_backend_array',
    'required'                   => 0,
    'user_defined'               => 0,
    'visible'                    => 1,
    'is_filterable'              => 1,
    'is_configurable'            => 0,
    'sort_order'                 => 14,
    'source'                     => 'ho_subviews/attribute_source_subview',
    'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'group'                      => 'General',
    'used_in_product_listing'    => true,
));

如您所见,我已经使用了自定义源来填充多选择字段。保存和加载值就像魅力一样。

可以使用:$ collection-> addattributetofilter('show_in_subview',array('finset'=> mage :: app() - > getStore() - > getCurrentsUbviewId()));

问题是该集合不使用索引,因为未设置列类型(http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set).

我注意到,在添加普通的多选字段时,查询是Catalog_product_index_eav表上的一个连接,该表确实使用索引,因此将更具性能。

我不确定在哪里可以使用此表。我猜想后端类是负责的(这是手动创建的下拉字段或上面的唯一区别)。因此,eav/entity_attribute_backend_array不使用catalog_product_index_eav表。

  • 用于多选择的默认后端是什么?
  • 如何扩展eav/entity_attribute_backend_array,以便使用catalog_product_index_eav表?
有帮助吗?

解决方案

最后,我使用了默认的多选属性。使用该解决方案,我们错过了一些灵活性,但是由于子视图并没有改变Thát,因此这不是问题。

  • 默认属性使用索引,这很快
  • 默认属性与SOLR后端兼容
许可以下: CC-BY-SA归因
scroll top