magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Product list does not contain extension_attributes stock_item

Open Kannakiraj123 opened this issue 2 years ago • 31 comments

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

Kannakiraj123 avatar Dec 15 '22 12:12 Kannakiraj123

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

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

:information_source: 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.

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

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: 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.

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

m2-assistant[bot] avatar Dec 15 '22 12:12 m2-assistant[bot]

@magento run all tests

Kannakiraj123 avatar Dec 15 '22 12:12 Kannakiraj123

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.

@magento run all tests

Kannakiraj123 avatar Dec 16 '22 04:12 Kannakiraj123

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.

Hi @sidolov, I saw your comments at https://github.com/magento/magento2/pull/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 :)

swnsma avatar Dec 24 '22 18:12 swnsma

@magento run all tests

Kannakiraj123 avatar Jan 02 '23 06:01 Kannakiraj123

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.

@magento run all tests

Kannakiraj123 avatar Jan 04 '23 10:01 Kannakiraj123

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.

@magento run all tests

swnsma avatar Jan 08 '23 10:01 swnsma

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.

@magento run all tests

swnsma avatar Jan 08 '23 13:01 swnsma

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.

@magento run all tests

Kannakiraj123 avatar Jan 17 '23 08:01 Kannakiraj123

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.

@magento run all tests

Kannakiraj123 avatar Jan 17 '23 10:01 Kannakiraj123

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.

@magento run all tests

Kannakiraj123 avatar Jan 17 '23 11:01 Kannakiraj123

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.

@magento run all tests

swnsma avatar Jan 17 '23 19:01 swnsma

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.

@magento run all tests

swnsma avatar Aug 29 '23 09:08 swnsma

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@swnsma Hi, is there any further progress on this?

cykolln avatar Apr 23 '24 21:04 cykolln

Any updates on above are the changes fine?

rohit-evrig avatar Jul 29 '24 11:07 rohit-evrig

@magento run all tests

engcom-Hotel avatar Oct 16 '24 06:10 engcom-Hotel

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

engcom-Hotel avatar Oct 16 '24 10:10 engcom-Hotel

@magento run all tests

engcom-Bravo avatar Oct 17 '24 08:10 engcom-Bravo

Hi @Kannakiraj123,

Thanks for the collaboration & contribution!

:heavy_check_mark: 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: :heavy_multiplication_x: 

Screenshot 2024-10-17 at 12 22 17

After: :heavy_check_mark:

Screenshot 2024-10-17 at 14 32 06

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

Thanks.

engcom-Bravo avatar Oct 17 '24 11:10 engcom-Bravo