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

Created on 5 May 2019  Â·  19Comments  Â·  Source: magento/magento2

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
Webapi Confirmed Format is valid Ready for Work P3 ready for dev Reproduced on 2.2.x Reproduced on 2.3.x S3

Most helpful comment

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?

All 19 comments

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

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: :point_down:

  • [ ] 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.

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

@AlexWorking @vteofilo

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

Thanks & Regards

@MagentoAr , please look at my solution:

https://github.com/magento/magento2/issues/15201#issuecomment-417867348

Hope this helps!

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

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

Can you find the StockRegistry.php class?

@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

@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.

@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

@vteofilo
any help would be great

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?

:white_check_mark: 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._

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?

okay great..
could you please tell me if there is any quick solution?
i'm too late to finish this task for my client.

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.

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.


Hi Guys,

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

Thanks!

✅ 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

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.

Was this page helpful?
0 / 5 - 0 ratings