Magento solr search - 如何向产品搜索索引添加自定义字段

时间:2012-05-24 17:21:55

标签: magento search solr

我有企业magento 1.10,我需要将自定义字段添加到solr索引,以便获得更好的搜索结果。此自定义字段应包含索引产品的类别名称。

我需要知道我需要修改哪部分magento。我修改了方法Enterprise_Search_Model_Resource_Index :: _ getCatalogCategoryData,它实际上产生了一些类别相关的数据但我的新字段没有出现在sorl的消息中。

我错过了什么吗?

此处我也有一些注意事项,也许有人帮助http://docs.nostresscommerce.com:8090/pages/viewpage.action?pageId=2490371

我重写的Enterprise_Search_Model_Resource_Index :: _ getCatalogCategoryData的输出,我在solr中需要category_name_level_ *。

  [result] => Array
        (
            [12227] => Array
                (
                    [#categories] => Array
                        (
                            [0] => 2
                            [3] => 3235
                            [7] => 2765
                            [10] => 6672
                        )

                    [#show_in_categories] => Array
                        (
                            [1] => 6671
                            [2] => 6670
                            [4] => 3224
                            [5] => 3199
                            [6] => 3191
                            [8] => 2761
                            [9] => 2760
                        )

                    [#position_category_2] => 1
                    [#position_category_6671] => 120000
                    [#position_category_6670] => 120000
                    [#position_category_3235] => 0
                    [#position_category_3224] => 150000
                    [#position_category_3199] => 150000
                    [#position_category_3191] => 120000
                    [#position_category_2765] => 1
                    [#position_category_2761] => 250001
                    [#position_category_2760] => 250001
                    [#position_category_6672] => 0
                    [#visibility] => 4
                    [#category_name_level_1] => Array
                        (
                            [0] => BCC Root Category
                        )

                    [#category_name_level_4] => Array
                        (
                            [0] => Huishouden
                            [1] => Top wasmachines
                            [2] => Accessoires wasmachine
                        )

                    [#category_name_level_3] => Array
                        (
                            [0] => Beste Koop Shop
                            [1] => Top
                            [2] => Wasmachine
                        )

                    [#category_name_level_2] => Array
                        (
                            [0] => Acties
                            [1] => Speciale informatie pagina's
                            [2] => Huishouden
                        )

                    [#category_name_level_5] => Array
                        (
                            [0] => Wasmachines
                        )

                )

        )

非常感谢, 哈罗。

我找到了解决方案

class Xyz_Solrsearch_Model_Resource_Engine extends Enterprise_Search_Model_Resource_Engine {
    public function __construct()
    {
        $this->_advancedDynamicIndexFields[] = '#category_name_level_';
        parent::__construct();
    }
}

0 个答案:

没有答案