Open LeftoversTodayAppAdmin opened 1 month ago
Thanks for the report.
This should be a relatively straightforward one to solve. The problem is that currently neither the DefaultSearchPlugin nor the ElasticSearchPlugin are listening for the StockMovementEvent
, which is the event that gets published whenever the stock level is being changed for a ProductVariant.
In the case of the DefaultSearchPlugin, the event subscribers are defined here.
For the ElasticSearchPlugin they are defined here.
So if I just add something like this, it should be enough to keep the product variant stock level up to date in ElasticSearch?
this.eventBus.ofType(StockMovementEvent).subscribe(event => {
return this.elasticsearchIndexService.updateVariants(event.ctx, event.variants);
});
@LeftoversTodayAppAdmin yes, that seems like a good fix!
Pull Request: https://github.com/vendure-ecommerce/vendure/pull/3112
Describe the bug I am using ElasticSearch as the search backend and when I use Stripe Plugin to successfully complete a purchase, the search index for that product variant is not updated. As a result, the search results still have the inStock value set to true and shows an out of stock item in the search results. The products API shows the correct stock level immediately after the transaction and when the stock is allocated.
To Reproduce Steps to reproduce the behavior:
Expected behavior
Environment (please complete the following information):
Additional context Looks like DefaultSearchPluginInitOptions has a parameter called indexStockStatus, what is a similar option for ElasticSearch or is it enabled by default? Also is it the responsibility of the Stripe plugin to trigger a reindex for each variant in the order?