Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update search index on specific additional events #17

Open
nicoes opened this issue Apr 25, 2023 · 3 comments
Open

Update search index on specific additional events #17

nicoes opened this issue Apr 25, 2023 · 3 comments
Labels

Comments

@nicoes
Copy link

nicoes commented Apr 25, 2023

Is your feature request related to a problem? Please describe.
Atm we are running into a set-up specific challenge regarding updating the search index. We have created a plugin that will receive stock updates from a third party. We would like to update the search index accordingly. This could be achieved by dispatching a ProductVariantEvent if the stock update is received, which would be correct but also pretty broad. Because a different feature of the same plugin listens to the ProductVariantEvent as well to update product information in the third party system. So we would create a loop if we didn't do any additional checks.

Describe the solution you'd like
We reasoned that it would be nice to be able to update the search index upon the StockMovementEvent event also. It would be nice if this would be added to the plugin core or to be made configurable in the plugin. For the latter I am referring to a way of configuring (additional) events that should update the search index.

@michaelbromley
Copy link
Member

Yes that's a good suggestion.

Perhaps an elegant way of supporting this without needing to introduce any new config or APIs would be to simply export the internal SearchIndexService, which has methods like reindex() and updateVariants() which, when called, will send jobs to the queue for processing.

In this way, you could inject the service into your own plugin and call it from an eventbus subscriber function.

@nicoes
Copy link
Author

nicoes commented Apr 28, 2023

All right. Thanks. We will look into your proposed way of supporting this. Do you see that as equally "correct" from a design point of view? Or would you switch to an event based solution when supported? Because it feels like tighter coupling between plugins.

@michaelbromley
Copy link
Member

I think the event-based approach does indeed have the edge due to the looser coupling. I'll have a think about a good API for this for the next update to this plugin. Feel free to contribute any ideas for the kind of API you'd like to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants