November Happy Hour will be moved to Thursday December 5th.

Promotion products index update

Vote:
 

Hi.

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.

#192380
May 16, 2018 8:51
Vote:
 

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.

#192382
May 16, 2018 9:19
Vote:
 

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.

#192383
May 16, 2018 9:30
Vote:
 

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

#192413
Edited, May 16, 2018 14:07
Vote:
 

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. :)

#192414
May 16, 2018 14:14
Vote:
 

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

#192415
May 16, 2018 14:20
Vote:
 

Will do. :)

#192416
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.