Magento 2. Modify product price in search

magento2
algoliasearch

#1

Good evening.

Products loading by search or on category page. I use algolia. But when in loading process I need to change price of each product.

Firstly I need to get ids of products from use Algolia. How to get them?

Secondly I need to get prices from some external resource by these ids.

Thirdly need to change price of each id.

I know need to use some event.

At this moment I have added and included algoliaPrice.js to my magento module:

requirejs(['algoliaBundle'], function (algoliaBundle) {
    algoliaBundle.$(function ($) {
        var algoliaConfig = window.algoliaConfig;
        console.log(algoliaConfig);
    });
});

So how to get ids of products from search use algolia functionality?

Thanks for any help and advise.


#2

Hello @faltsman,

There are some javascript frontend hooks to help you customize your results :
https://community.algolia.com/magento/doc/m2/frontend-events/

We also created a customization extension to help customers : https://community.algolia.com/magento/doc/m2/customize-extension/

But I guess, the easiest way to update your prices should be at indexing time with the backend hooks : https://community.algolia.com/magento/doc/m2/backend/#algoliaproductindexbefore

Example : https://community.algolia.com/magento/doc/m2/transform-attribute/

Hope this would help.
Best.
Damien

But I guess