SaaS CMS has officially launched! Learn more now.

Promotion products index update



I faced an issue that products/variants included into promotion are not getting re-indexed on promotion change. Is this feature not implemented at all, or I'm doing something wrong? Find search is in use if It's matter.

If this functionality is not available OOTB, if there any way to attach to promotion/campaign lifecycle to get events about promotion creation/update/removal/expiration? Because right now, the only solution I came up with is to create a job that will reindex such products nightly, but obviously It looks like a bad idea.

Thank you.

May 16, 2018 8:51

You are right, it is not supported out of the box. We thought and talked about it, and it is actually more complicated than it sounds, if you consider campaigns and promotions can be scheduled/expired. Using scheduled job to reindex is not a bad idea, but you can use the existing one, no?

We will keep that problem in mind, maybe some day we will be able to solve it nicely.

May 16, 2018 9:19

Yes, that will do the job, but I was thinking about something more specific, that would allow to reindex only affected products instead of a whole catalog.

Thank you for prompt reply.

May 16, 2018 9:30

It's quite an annoying issue indeed. But since promotions are IContent too, you can try with the approach of creating an IInitializableModule that makes use of IContentEvents and it's SavingContent event.

Then checking if the content being saved is a promotion that has lists of references to products/variants.

Then finally passing those references to the IContentIndexer.IndexFrom-method.

One hurdle to get past is when removing products from a campaign, these should get indexed too I presume. I haven't come up with something for this case yet. Maybe loading the content from the db (IContentRepository) during the SavingContent-event to get them from there?

Hopefully this can give you some inspiration on things to try, but as Quan said it isn't super simple. :P

Edited, May 16, 2018 14:07

Thanks for sharing your thoughts. I decided to stick to a whole catalog reindexing so far. May be will replace It with some elegant solution in future. :)

May 16, 2018 14:14

If you come up with an elegant solution before we do, please share :) 

May 16, 2018 14:20

Will do. :)

May 16, 2018 14:21
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.