1

Dears, I am using this API in search:

GET http://domain.com/index.php/rest/V1/search

Parameters:

searchCriteria[requestName]= quick_search_container
searchCriteria[filterGroups][0][filters][0][field] = search_term
searchCriteria[filterGroups][0][filters][0][value] = life

But I always retrieve products results without image as:

{"items":[{"id":211,"custom_attributes":[{"attribute_code":"score","value":"91.9732208251953100"}]},{"id":483,"custom_attributes":[{"attribute_code":"score","value":"91.9732208251953100"}]},{"id":46,"custom_attributes":[{"attribute_code":"score","value":"91.9732208251953100"}]},{"id":50,"custom_attributes":[{"attribute_code":"score","value":"91.9732208251953100"}]},{"id":40,"custom_attributes":[{"attribute_code":"score","value":"5.7483263015747070"}]},{"id":41,"custom_attributes":[{"attribute_code":"score","value":"5.7483263015747070"}]},{"id":45,"custom_attributes":[{"attribute_code":"score","value":"5.7483263015747070"}]}],"aggregations":{"buckets":[{"name":"category_bucket","values":[{"value":"3","metrics":["3","2"]},{"value":"6","metrics":["6","2"]},{"value":"7","metrics":["7","1"]},{"value":"8","metrics":["8","1"]},{"value":"9","metrics":["9","3"]},{"value":"10","metrics":["10","3"]},{"value":"12","metrics":["12","2"]},{"value":"15","metrics":["15","1"]},{"value":"16","metrics":["16","1"]}]}],"bucket_names":["category_bucket"]},"search_criteria":{"request_name":"quick_search_container","filter_groups":[{"filters":[{"field":"search_term","value":"life","condition_type":"eq"}]}]},"total_count":7}

How can I retrieve product details included images ?

  • have you get any feasible solution ?? – user4536 Apr 18 at 12:03
  • Do it as custom API – Jsparo30 Apr 18 at 13:54
  • please provide any reference if any – user4536 Apr 24 at 6:31
2

If you want to perform a fulltext search, the native API you used returns only the product IDs (from the search engine : Mysql or ElasticSearch) that match the search term.

Two approaches :

  1. Do another API calls in order to have product details based on the IDs returned (not perfect for performance)
  2. Create your own API based on this search API in order to load the product collection based on the product IDs retrieved.

It is feasible but need code customization.

Internally, Magento uses this search API request, then store the result in a temp table in order to load the product collection in a second time to display product listing in frontend sorted by score.

  • @Frank, Thank you. It is bad design to call another API to get product details. Can you please check this question magento.stackexchange.com/questions/186036/… ? – Jsparo30 Jul 25 '17 at 13:23
  • Yes, it is recommended to create your own API endpoint and manage the logic inside to format the response based on your search term. I did it on my project by creating a custom ElasticSearch request then loading the product collection filtering by product IDs returned. The best but the hard is to store all your information in ElasticSearch and then retrieve information only from ElasticSearch without Magento SQL requests. – Franck Garnier Jul 25 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.