简体   繁体   中英

Joomla Smart Search indexer not updating when I update custom content

I've built a custom component to handle client data, along with a plugin for the Smart Search component to find, index, and include them in searches. Thus far, everything works; the indexer sees my component, it's indexing the relevant content I'm asking it to, and search results include relevant client data.

The issue I'm having is that if/when a client's information is changed or a new client is added, the index does not update to include these changes.

Surely I've just missed a vital component/function somewhere, but despite digging through what documentation I can find and the already existing Joomla components/indexers, I can't find whatever it is that I'm missing for this to function.

After much testing and digging through various files, I have found the answer.

By default, Joomla has configured plugins that hook onto the various events triggered throughout the save process. From there the plugins themselves trigger the finder events that update indexes.

The solution, without making a plugin similar to what Joomla does, was to add this code after a model/table/etc successfully performed a save:

Joomla\CMS\Plugin\PluginHelper::importPlugin('finder');
Joomla\CMS\Factory::getApplication()->triggerEvent('onFinderAfterSave', [$context, $row, $isNew]);

The various variables being sent as a part of the events are explained in adequate detail in any of the plugins that are included in Joomla.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM