Implementing Custom Search Index
Sometimes it's need to have specific type of Index, which is either not included to our extension, or belongs to some third-party extension. In this case custom index can be implemented, using the following instructions:
- Clone the example module from repository http://github.com/mirasvit/module-search-extended
- Go to
app/code/Mirasvit/SearchExtended/Index/and rename subpathMagento/Review/Review/to the required one([provider]/[module]/[entity]) - Change class names in file
app/code/Mirasvit/SearchExtended/Index/[provider]/[module]/[entity]/Index.php- Rename class
- Set your values to
getName(),getPrimaryKey()andgetIdentifier()methods
- Configure the attributes you want to get in
getAttributes()method - Change methods
buildSearchCollection()andgetSearchableEntities() - Change registration for new index in file
app/code/Mirasvit/SearchExtended/etc/di.xml -
Adjust layout file
app/code/Mirasvit/SearchExtended/view/frontend/layout/catalogsearch_result_index.xmlRename template name/path and adjust it
/app/code/Mirasvit/SearchExtended/view/frontend/templates/index/magento/review/review.phtml - Enable module and Clear magento cache
If everything was correct, you can add index of your custom type like any regular index.
- If you use SSU please go to:
/vendor/mirasvit/module-search-autocomplete/src/SearchAutocomplete/Model/Indexfolder - Create folder/file structure
<Company>/<Extension>/<EntityType>.phpi.e./vendor/mirasvit/module-search-autocomplete/src/SearchAutocomplete/Model/Index/Ves/Blog/Post.php - Open
/vendor/mirasvit/module-search-autocomplete/src/SearchAutocomplete/etc/di.xmland add item to typename="Mirasvit\SearchAutocomplete\Model\Index\Pool"arguments