Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"/rest/V1/products?searchCriteria" API endpoint" does not return information about stock in the "extension_attributes" section #22737

Closed
menacoders opened this issue May 5, 2019 · 24 comments
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P3 May be fixed according to the position in the backlog. Progress: done Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue

Comments

@menacoders
Copy link

menacoders commented May 5, 2019

Preconditions

  1. Magento 2.2.7 community Edition.
  2. REST API filtering products using rest/V1/products?searchCriteria

Steps to reproduce

  1. we have disable showing out of stock products from Magento Dashboard (Stores > Configuration > Catalog > Inventory > Display Out of stock products No)
  2. we using this api to filtering product
    /rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=35&searchCriteria[current_page]=1&searchCriteria[page_size]=40

Expected result

  1. The response contains infromation about stock per each product in the "extension_attributes" section

Actual result

  1. There is no information about stock status per product in "extension_attributes" and no possibility to understand is it available on Storefront
@m2-assistant
Copy link

m2-assistant bot commented May 5, 2019

Hi @MagentoAr. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@MagentoAr do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 5, 2019
@AlexWorking AlexWorking self-assigned this May 5, 2019
@m2-assistant
Copy link

m2-assistant bot commented May 5, 2019

Hi @AlexWorking. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@menacoders
Copy link
Author

Hi @AlexWorking
thank you very much for working on this issue.
i'll waiting your updates.

@menacoders
Copy link
Author

@AlexWorking @vteofilo

any help in this issue would be great..
it's urgent problem in our store .

Thanks & Regards

@vteofilo
Copy link

vteofilo commented May 8, 2019

@MagentoAr , please look at my solution:

#15201 (comment)

Hope this helps!

@vteofilo
Copy link

vteofilo commented May 8, 2019

@vteofilo
thank you but i really don't know where to put your code.

Can you find the StockRegistry.php class?

@vteofilo
Copy link

vteofilo commented May 8, 2019

@vteofilo
thank you but i really don't know where to put your code.

Can you find the StockRegistry.php class?

yes i found it on this path
/vendor/magento/module-catalog-inventory/Model/StockRegistry.php

but i don't know wheres to put the code

You must override the syncProductStock method.

@menacoders
Copy link
Author

@vteofilo
thank you but i really don't know where to put your code.

Can you find the StockRegistry.php class?

yes i found it on this path
/vendor/magento/module-catalog-inventory/Model/StockRegistry.php
but i don't know wheres to put the code

You must override the syncProductStock method.

i couldn't find any method called syncProductStock in this file
/vendor/magento/module-catalog-inventory/Model/StockRegistry.php

@menacoders
Copy link
Author

@vteofilo
any help would be great

@sdzhepa
Copy link
Contributor

sdzhepa commented May 8, 2019

Hello @MagentoAr

Thank you for the report!

We investigated this issue and as results:

  1. Initially "/rest/V1/products?searchCriteria" API endpoint was developed for wider use and it should not returns only In Stock products by design.
    Even if you set "Stores > Configuration > Catalog > Inventory > Display Out of stock products No" the product will be available by direct URL on Storefront.
    I suppose it needs for SEO purposes and indexation by other systems.
    And because of that issue cannot be confirmed and proved for fix with described use case

  2. But the real bug is "/rest/V1/products?searchCriteria" API endpoint" does not return information about stock in the "extension_attributes" section.

so, I updated Issue title and description with this information
Are you ok with this?

@sdzhepa sdzhepa changed the title out of stock products still appear in searchCriteria rest api "/rest/V1/products?searchCriteria" API endpoint" does not return information about stock in the "extension_attributes" section May 8, 2019
@sdzhepa sdzhepa added the Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" label May 8, 2019
@sdzhepa sdzhepa added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels May 8, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label May 8, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @sdzhepa
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-99618, MAGETWO-99619 were created

Issue Available: @sdzhepa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@milindsingh milindsingh self-assigned this May 10, 2019
@m2-assistant
Copy link

m2-assistant bot commented May 10, 2019

Hi @milindsingh. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@mallikaverma mallikaverma self-assigned this May 11, 2019
@m2-assistant
Copy link

m2-assistant bot commented May 11, 2019

Hi @mallikaverma. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.


@dwang12
Copy link

dwang12 commented Aug 12, 2019

Hi Guys,

We're also experiencing this in a production setting. Any updates would be greatly appreciated.

Thanks!

@ghost ghost unassigned milindsingh and mallikaverma Sep 27, 2019
@farhansaid127
Copy link

✅ Confirmed by @sdzhepa
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-99618, MAGETWO-99619 were created

Issue Available: @sdzhepa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

But we are still not able to find if product available in stock or not, there is no parameter in search result that shows whether the product available in stock or out of stock

@farhansaid127
Copy link

Hello @MagentoAr

Thank you for the report!

We investigated this issue and as results:

  1. Initially "/rest/V1/products?searchCriteria" API endpoint was developed for wider use and it should not returns only In Stock products by design.
    Even if you set "Stores > Configuration > Catalog > Inventory > Display Out of stock products No" the product will be available by direct URL on Storefront.
    I suppose it needs for SEO purposes and indexation by other systems.
    And because of that issue cannot be confirmed and proved for fix with described use case
  2. But the real bug is "/rest/V1/products?searchCriteria" API endpoint" does not return information about stock in the "extension_attributes" section.

so, I updated Issue title and description with this information
Are you ok with this?

But we are still not able to find if product available in stock or not, there is no parameter in search result that shows whether the product available in stock or out of stock.

@VladimirZaets VladimirZaets added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Jun 18, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: ready for dev labels Sep 24, 2020
@ghost ghost unassigned kirtinariya1 Oct 19, 2020
@m2-community-project m2-community-project bot added Progress: ready for dev and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Oct 19, 2020
@scne
Copy link

scne commented Jan 2, 2021

any news about this issue?

@menacoders
Copy link
Author

menacoders commented Jan 4, 2021

any news about this issue?

@scne
it's still not fixed in any version
i have built a module to solve this issue, i'll share it with you these days.

@menacoders
Copy link
Author

menacoders commented Jan 4, 2021

Hi @scne
i have uploaded the module, get it from here
https://github.com/menacoders/Stock-Info-API-searchCriteria

and let me know if you need anything else 👍

@scne
Copy link

scne commented Jan 4, 2021

Hi @menacoders thank you so much for your help! I'm using Magento 2.3.2, is your code compliant?

@menacoders
Copy link
Author

Hi @menacoders thank you so much for your help! I'm using Magento 2.3.2, is your code compliant?

yes, i have build it for m2.3.x

@titechnologies
Copy link

Hi @scne
i have uploaded the module, get it from here
https://github.com/menacoders/Stock-Info-API-searchCriteria

and let me know if you need anything else

Thank you.
One question, how can we filter out these out-of-stock products from the API result?

@menacoders
Copy link
Author

menacoders commented Jan 6, 2021

Hi @scne
i have uploaded the module, get it from here
https://github.com/menacoders/Stock-Info-API-searchCriteria
and let me know if you need anything else

Thank you.
One question, how can we filter out these out-of-stock products from the API result?

@titechnologies
you are welcome.

you mean, you only want to return the in_stock products ?
if that what you want.. you could use this api

rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=quantity_and_stock_status&searchCriteria[filter_groups][0][filters][0][value]=2

just add the quantity_and_stock_status filter so it's will return the in_stock products
instock value = 2
outofstock value = 1

@stale
Copy link

stale bot commented Mar 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P3 May be fixed according to the position in the backlog. Progress: done Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. stale issue
Projects
Development

Successfully merging a pull request may close this issue.