How to modify results with infiniteHits

Hi,

I’m using infiniteHits in instantsearch.js in magento.
I need to modify the items before they are displayed, but I’ll need to modify them as a whole, not one by one. THis is because I might remove and/or add some as well.
However the infiniteHits transformData function doesn’t seem to have an allItems property. Is that true? Is there another way to achive that?

regards
Alex

Hi,

All items will be passed through the options.transformData.item method. It will modify all your items.

Can you provide more details on what you’re trying to achieve?

Hi,
I know that, and basically this is working. However, I do have some custom code in place that might need to remove or add an item.
Now, the items Method get’s a single item passed. I can’t return two items when I need to add one. Using the allItems this was straight forward, as I could just modify the array as needed.
My current workaround is that I double wrap my results:
I return an object containing an array containg my actual hits. This array can then contain more than one entry, and I unfiddel this all in the template.

regards
Alex

1 Like