We are using Glue API’s /catalog-search endpoint t...
# help
v
We are using Glue API’s /catalog-search endpoint to fetch paginated set of products that we use in our headless storefront implementation. Default parameters for the catalog sorting seem to be rating, name_asc, name_desc, price_asc and price_desc. However, we need to able to sort products by ‘newest’ or ‘latest’. Is there a way to expand Glue API so that we can use our own sorting parameters and use those parameters to create custom catalog sorting rule on the backend side?
w
Yes, please have a look at
\Spryker\Client\SearchElasticsearch\Plugin\QueryExpander\SortedQueryExpanderPlugin
For the specific newest/latest sorting you are asking for you probably need to add the data first. This can be done via a plugin during the publishing.
\Spryker\Zed\ProductPageSearch\Communication\Plugin\ProductPageSearch\Elasticsearch\ProductPriceMapExpanderPlugin::expandProductMap
could serve as a good example for such a plugin
v
Thank you very much! I will take a look into those methods!
Hello @wooden-king-30682, I have made the changes, but I faced one issue: When the Elasticsearch expander class is called? Seems that it's not called when I search products or add new product..
Spryker\Zed\ProductPageSearch\Communication\Plugin\ProductPageSearch\Elasticsearch\ProductPriceMapExpanderPlugin::expandProductMap
w
The expander is called when a product is published into the search. This happens asynchronously when Jenkins executes the queue_worker_start Job and is therefore not that easy to debug. Locally you can disable this jenkins job, trigger a publishing of the product you want to publish
docker/sdk console publish:trigger-events -r product_abstract -i <product abstract id>
and debug the processing afterwards
docker/sdk console -x queue:task:start publish
.