2

I try to get all active products with a quantity less then 5. I getall active products via

V1/products/?searchCriteria[filter_groups][0][filters][0][field]=status&searchCriteria[filter_groups][0][filters][0][value]=1&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

But how do I add a filter to a quantity <5 ? I added this criteria, but it didnt work:

&searchCriteria[filter_groups][0][filters][1][field]=extension_attributes[stock_item[qty]]&searchCriteria[filter_groups][0][filters][1][value]=5&searchCriteria[filter_groups][0][filters][1][condition_type]=lt

Can somebody explan how to create a searchCriteria for nested fields? Because I think this seems to be the problem here...

5
  • what magento version are you suing? are you using multisource-inventory? Oct 24, 2019 at 15:15
  • magento v2.2.3, and no multisource-inventory
    – Java_Waldi
    Oct 24, 2019 at 15:37
  • by taking a quick look at your query, I noticed a typo: &searchCriteria[filter_groups][0][filters][1][field]=extension_attributes[stock_item][qty]&searchCriteria[filter_groups][0][filters][1][value]=5&searchCriteria[filter_groups][0][filters][1][condition_type]=lt it has to be [stock_item][qty] and not [stock_item[qty]]. i have not tested this Oct 25, 2019 at 7:42
  • that's wring because qty is nested in "stock_item" which is nested in "extension_attributes"
    – Java_Waldi
    Oct 25, 2019 at 11:23
  • did you finally find a way through this ?
    – Kai23
    Jan 14 at 10:17

1 Answer 1

0

I researched the documentation as of 2.4 there is no way to filter products based on quantity, so the only option left is to extend the rest api with some custom module.

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.