Skip to content

Product list does not contain extension_attributes stock_item #36615

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

Conversation

Kannakiraj123
Copy link
Contributor

Description (*)

This pull request (PR) will be merge the added stock item extension_attributes in product list rest API /rest/V1/products?searchCriteria

Related Pull Requests

1.I added observer for "catalog_product_collection_load_after" in cataloginventory module.

Fixed Issues (if relevant)

  1. Fixes Product list does not contain [extension_attributes][stock_item] #36533

Manual testing scenarios (*)

1.Open the Postman

2.Add the API URL: {baseurl}/rest/V1/products?searchCriteria

3.Method: GET

4.Authorization "Use Admin Token"

5.Check in response There is a "stock_item": object added in extension_attributes section.

@m2-assistant
Copy link

m2-assistant bot commented Dec 15, 2022

Hi @Kannakiraj123. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Dec 15, 2022
@m2-github-services m2-github-services added Partner: EY partners-contribution Pull Request is created by Magento Partner labels Dec 15, 2022
@Kannakiraj123
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@Kannakiraj123
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Kannakiraj123,
Thank you for your contribution!

Could you please check my comment to the PR?

Also, regarding of definition of done I need to ask you to cover new functionality with auto-tests.

@swnsma
Copy link
Contributor

swnsma commented Dec 24, 2022

Hi @sidolov, I saw your comments at #28435 and may disagree with the current implementation.
So far we have:

  • Stock item available for the single loaded product (\Magento\CatalogInventory\Model\Plugin\AfterProductLoad)
  • Inventory data is being processed and saved (\Magento\CatalogInventory\Observer\SaveInventoryDataObserver)

Missing inventory data in the collection load cause inconsistency in logic and also violate current documentation.
Moreover, seems that functionality is in demand by the community.

My suggestion is to introduce such functionality (mentioned in this PR).
However, declaring it as deprecated from the very beginning, so it may be removed in some bright future altogether with the other two Inventory integration points mentioned in the current Pull Request.

The only I am not sure about is should stock data be loaded altogether with product collection in the Persistance layer (as it happens for a single product now) or should be moved to Service Layer (e.g. around Repository get list method).

Your opinion is more than welcome here :)

@Kannakiraj123
Copy link
Contributor Author

@magento run all tests

@rohit-evrig
Copy link

Any updates on above are the changes fine?

@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel
Copy link
Contributor

@magento run Database Compare, Functional Tests B2B, Functional Tests EE, Functional Tests CE, WebAPI Tests, Integration Tests

Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failed tests seem flaky to me, hence approving the PR.

@engcom-Bravo
Copy link
Contributor

@magento run all tests

@engcom-Bravo
Copy link
Contributor

Hi @Kannakiraj123,

Thanks for the collaboration & contribution!

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop

Steps to reproduce

1.Open the Postman
2.Add the API URL: {baseurl}/rest/V1/products?searchCriteria
3.Method: GET
4.Authorization "Use Admin Token"
5.Check in response There is a "stock_item": object added in extension_attributes section.

Before: ✖️ 

Screenshot 2024-10-17 at 12 22 17

After: ✔️

Screenshot 2024-10-17 at 14 32 06

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks.

@engcom-Dash engcom-Dash self-assigned this Oct 21, 2024
@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run Database Compare, WebAPI Tests, Integration Tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

Hello @Kannakiraj123,

Thank you for your contributions.

We are closing this PR because Magento has deprecated the stock item as an extension attribute. Additionally, it is causing a DB test failure and may even impact performance. Magento provides a separate API for retrieving stock-related data: Stock Items API.

If you need stock information, you should load products using the repository and retrieve the stock data via the API in a separate request.

Thank you again for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: EY partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Priority: P3 May be fixed according to the position in the backlog. Project: Community Picked PRs upvoted by the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Product list does not contain [extension_attributes][stock_item]
9 participants