Magento2 Products filter quantity_and_stock_status is not workingUsing searchCriteria while searching attributes in magento 2.0Regarding product list API to get only list of product for one store via REST API Magento2REST Api Products response not showing extension attributesMagento2 rest api error on product search on extension attributeMagento 2 Rest Api get Products List including qty fieldMagento 2 filter products by price from Rest APIorder api search criteriaHow to load another language variables by REST APIMagento 2 Rest Api - Is this searchCriteria filter correct?Get product data between 2 dates using filters in get product rest API magento2

Do other countries guarantee freedoms that the United States does not have?

WordCloud: do not eliminate duplicates

Premier League simulation

Should I take out a personal loan to pay off credit card debt?

Non-OR journals which regularly publish OR research

Where to pee in London?

Did WWII Japanese soldiers engage in cannibalism of their enemies?

How to avoid ci-driven development..?

What does VB stand for?

Is there a loss of quality when converting RGB to HEX?

Decode a variable-length quantity

Casting Goblin Matron with Plague Engineer on the battlefield

How quickly could a country build a tall concrete wall around a city?

How do I change the output voltage of the LM7805?

How does the oscilloscope trigger really work?

How to realistically deal with a shield user?

Can a PC attack themselves with an unarmed strike?

Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?

Is this cheap "air conditioner" able to cool a room?

How would a family travel from Indiana to Texas in 1911?

Need help understanding lens reach

Erratic behavior by an internal employee against an external employee

What was the first multiprocessor x86 motherboard?

How would I as a DM create a smart phone-like spell/device my players could use?



Magento2 Products filter quantity_and_stock_status is not working


Using searchCriteria while searching attributes in magento 2.0Regarding product list API to get only list of product for one store via REST API Magento2REST Api Products response not showing extension attributesMagento2 rest api error on product search on extension attributeMagento 2 Rest Api get Products List including qty fieldMagento 2 filter products by price from Rest APIorder api search criteriaHow to load another language variables by REST APIMagento 2 Rest Api - Is this searchCriteria filter correct?Get product data between 2 dates using filters in get product rest API magento2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















We are developing an iOS app for a Magento website using Magento2 rest apis. App is fetching and showing all products added to the magneto website. But some of the products are not being added to the customer/guest cart as they are unavailable as of now.




In order to achieve this functionality we have added a new filter to show the products based on their stock and quantity's availability status.
for this we have added "quantity_and_stock_status" filter to the products api, which is not working.




Here are the details of the api we have implemented for filtration of products:



func fetchItems(field:String?, value:String?) 
//Check for internet connection.
guard self.isNetworkAvailable() == true else
return

self.showProgressHUD()

var productSearchAPI = API.host + "/rest/V1/products?"
if let fieldName = field, let fieldValue = value
productSearchAPI += "searchCriteria[filter_groups][0][filters][0][field]=(fieldName)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][value]=(fieldValue)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&"


productSearchAPI += "searchCriteria[filter_groups][0][filters][1][field]=status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][value]=1"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][condition_type]=eq&"

/*productSearchAPI += "searchCriteria[filter_groups][0][filters][2][field]=quantity_and_stock_status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][value]=0"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][condition_type]=gt&"*/

productSearchAPI += "searchCriteria[pageSize]=(pageSize)"
productSearchAPI += "&searchCriteria[currentPage]=(currentPage)"

Alamofire.request(productSearchAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: ["Authorization":API.key]).responseJSON response in

self.hideProgressHUD()
guard let JSON = response.result.value as? [String:AnyObject], let items = JSON["items"] as? [[String:AnyObject]], let pages = JSON["total_count"] as? Int else
return

if self.currentPage == 1
self.items = items
else
self.items?.append(contentsOf: items)

self.totalPages = pages
self.collectionView.reloadData()




Can you please help us by pointing what is wrong with our product list filter's implementation?










share|improve this question


























  • Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

    – KAndy
    Jul 29 at 9:37











  • Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

    – KAndy
    Jul 29 at 9:39











  • So on what basis we can filter our product list and show only available products only?

    – Rajender Kumar
    Jul 29 at 9:49











  • Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

    – KAndy
    Jul 29 at 10:08











  • Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

    – Rajender Kumar
    Jul 29 at 11:25


















1















We are developing an iOS app for a Magento website using Magento2 rest apis. App is fetching and showing all products added to the magneto website. But some of the products are not being added to the customer/guest cart as they are unavailable as of now.




In order to achieve this functionality we have added a new filter to show the products based on their stock and quantity's availability status.
for this we have added "quantity_and_stock_status" filter to the products api, which is not working.




Here are the details of the api we have implemented for filtration of products:



func fetchItems(field:String?, value:String?) 
//Check for internet connection.
guard self.isNetworkAvailable() == true else
return

self.showProgressHUD()

var productSearchAPI = API.host + "/rest/V1/products?"
if let fieldName = field, let fieldValue = value
productSearchAPI += "searchCriteria[filter_groups][0][filters][0][field]=(fieldName)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][value]=(fieldValue)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&"


productSearchAPI += "searchCriteria[filter_groups][0][filters][1][field]=status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][value]=1"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][condition_type]=eq&"

/*productSearchAPI += "searchCriteria[filter_groups][0][filters][2][field]=quantity_and_stock_status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][value]=0"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][condition_type]=gt&"*/

productSearchAPI += "searchCriteria[pageSize]=(pageSize)"
productSearchAPI += "&searchCriteria[currentPage]=(currentPage)"

Alamofire.request(productSearchAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: ["Authorization":API.key]).responseJSON response in

self.hideProgressHUD()
guard let JSON = response.result.value as? [String:AnyObject], let items = JSON["items"] as? [[String:AnyObject]], let pages = JSON["total_count"] as? Int else
return

if self.currentPage == 1
self.items = items
else
self.items?.append(contentsOf: items)

self.totalPages = pages
self.collectionView.reloadData()




Can you please help us by pointing what is wrong with our product list filter's implementation?










share|improve this question


























  • Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

    – KAndy
    Jul 29 at 9:37











  • Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

    – KAndy
    Jul 29 at 9:39











  • So on what basis we can filter our product list and show only available products only?

    – Rajender Kumar
    Jul 29 at 9:49











  • Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

    – KAndy
    Jul 29 at 10:08











  • Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

    – Rajender Kumar
    Jul 29 at 11:25














1












1








1








We are developing an iOS app for a Magento website using Magento2 rest apis. App is fetching and showing all products added to the magneto website. But some of the products are not being added to the customer/guest cart as they are unavailable as of now.




In order to achieve this functionality we have added a new filter to show the products based on their stock and quantity's availability status.
for this we have added "quantity_and_stock_status" filter to the products api, which is not working.




Here are the details of the api we have implemented for filtration of products:



func fetchItems(field:String?, value:String?) 
//Check for internet connection.
guard self.isNetworkAvailable() == true else
return

self.showProgressHUD()

var productSearchAPI = API.host + "/rest/V1/products?"
if let fieldName = field, let fieldValue = value
productSearchAPI += "searchCriteria[filter_groups][0][filters][0][field]=(fieldName)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][value]=(fieldValue)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&"


productSearchAPI += "searchCriteria[filter_groups][0][filters][1][field]=status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][value]=1"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][condition_type]=eq&"

/*productSearchAPI += "searchCriteria[filter_groups][0][filters][2][field]=quantity_and_stock_status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][value]=0"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][condition_type]=gt&"*/

productSearchAPI += "searchCriteria[pageSize]=(pageSize)"
productSearchAPI += "&searchCriteria[currentPage]=(currentPage)"

Alamofire.request(productSearchAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: ["Authorization":API.key]).responseJSON response in

self.hideProgressHUD()
guard let JSON = response.result.value as? [String:AnyObject], let items = JSON["items"] as? [[String:AnyObject]], let pages = JSON["total_count"] as? Int else
return

if self.currentPage == 1
self.items = items
else
self.items?.append(contentsOf: items)

self.totalPages = pages
self.collectionView.reloadData()




Can you please help us by pointing what is wrong with our product list filter's implementation?










share|improve this question
















We are developing an iOS app for a Magento website using Magento2 rest apis. App is fetching and showing all products added to the magneto website. But some of the products are not being added to the customer/guest cart as they are unavailable as of now.




In order to achieve this functionality we have added a new filter to show the products based on their stock and quantity's availability status.
for this we have added "quantity_and_stock_status" filter to the products api, which is not working.




Here are the details of the api we have implemented for filtration of products:



func fetchItems(field:String?, value:String?) 
//Check for internet connection.
guard self.isNetworkAvailable() == true else
return

self.showProgressHUD()

var productSearchAPI = API.host + "/rest/V1/products?"
if let fieldName = field, let fieldValue = value
productSearchAPI += "searchCriteria[filter_groups][0][filters][0][field]=(fieldName)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][value]=(fieldValue)"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&"


productSearchAPI += "searchCriteria[filter_groups][0][filters][1][field]=status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][value]=1"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][1][condition_type]=eq&"

/*productSearchAPI += "searchCriteria[filter_groups][0][filters][2][field]=quantity_and_stock_status"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][value]=0"
productSearchAPI += "&searchCriteria[filter_groups][0][filters][2][condition_type]=gt&"*/

productSearchAPI += "searchCriteria[pageSize]=(pageSize)"
productSearchAPI += "&searchCriteria[currentPage]=(currentPage)"

Alamofire.request(productSearchAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: ["Authorization":API.key]).responseJSON response in

self.hideProgressHUD()
guard let JSON = response.result.value as? [String:AnyObject], let items = JSON["items"] as? [[String:AnyObject]], let pages = JSON["total_count"] as? Int else
return

if self.currentPage == 1
self.items = items
else
self.items?.append(contentsOf: items)

self.totalPages = pages
self.collectionView.reloadData()




Can you please help us by pointing what is wrong with our product list filter's implementation?







magento2 products rest-api stock-status stock-availability






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 29 at 9:23







Rajender Kumar

















asked Jul 29 at 9:11









Rajender KumarRajender Kumar

1062 bronze badges




1062 bronze badges















  • Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

    – KAndy
    Jul 29 at 9:37











  • Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

    – KAndy
    Jul 29 at 9:39











  • So on what basis we can filter our product list and show only available products only?

    – Rajender Kumar
    Jul 29 at 9:49











  • Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

    – KAndy
    Jul 29 at 10:08











  • Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

    – Rajender Kumar
    Jul 29 at 11:25


















  • Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

    – KAndy
    Jul 29 at 9:37











  • Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

    – KAndy
    Jul 29 at 9:39











  • So on what basis we can filter our product list and show only available products only?

    – Rajender Kumar
    Jul 29 at 9:49











  • Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

    – KAndy
    Jul 29 at 10:08











  • Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

    – Rajender Kumar
    Jul 29 at 11:25

















Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

– KAndy
Jul 29 at 9:37





Actually it's virtual attribute to represent stock information on product form. It does not persist in DB so you cannot filter by it. Also it represents two values, so how are you expect to filter by it?

– KAndy
Jul 29 at 9:37













Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

– KAndy
Jul 29 at 9:39





Also if you build client facing app, better to use GraphQL for it see devdocs.magento.com/guides/v2.3/graphql

– KAndy
Jul 29 at 9:39













So on what basis we can filter our product list and show only available products only?

– Rajender Kumar
Jul 29 at 9:49





So on what basis we can filter our product list and show only available products only?

– Rajender Kumar
Jul 29 at 9:49













Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

– KAndy
Jul 29 at 10:08





Rest API is not designed for that. To do it you need build your own view, and query it, or use GraphQL

– KAndy
Jul 29 at 10:08













Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

– Rajender Kumar
Jul 29 at 11:25






Thanks, we will try to learn GraphQL or implement custom api for querying products availability. However I still have a strong feeling that there should be a parameters provided by Magento for such kind of simple filtration.

– Rajender Kumar
Jul 29 at 11:25











0






active

oldest

votes














Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283629%2fmagento2-products-filter-quantity-and-stock-status-is-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283629%2fmagento2-products-filter-quantity-and-stock-status-is-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form