由于 Enterprise_Search 模块添加了一个默认每天凌晨 3 点运行的 cronjob,我找到了比在文件中添加一行代码更好的解决方案shell/abstract.php
。
您需要做的就是创建一个小模块,将某个事件添加到全局命名空间而不是管理员:
<?xml version="1.0"?>
<config>
<modules>
<YourNamespace_YourModuleName>
<version>0.0.1</version>
</YourNamespace_YourModuleName>
</modules>
<global>
<events>
<!-- The misspelling (cat-e-logsearch) is correct, you can look it up in the config.xml of the Enterprise_Search module -->
<catelogsearch_searchable_attributes_load_after>
<observers>
<enterprise_search>
<class>enterprise_search/observer</class>
<method>storeSearchableAttributes</method>
</enterprise_search>
</observers>
</catelogsearch_searchable_attributes_load_after>
</events>
</global>
</config>
不要忘记通过在以下位置放置另一个配置文件来激活您的模块app/etc/modules/YourNamespace_YourModuleName.xml
:
<?xml version="1.0"?>
<config>
<modules>
<YourNamespace_YourModuleName>
<active>true</active>
<codePool>local</codePool>
<depends>
<Enterprise_Search/>
</depends>
</YourNamespace_YourModuleName>
</modules>
</config>
现在,您可以通过从 Magento 根文件夹发出以下命令,从命令行重建 Solr 索引(当然,假设您具有 shell 访问权限):
php shell/indexer.php --reindex catalogsearch_fulltext