Skip to content

fix items getChilderen returns empty array for parent cart items when… #39793

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

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from

Conversation

Gerke-W
Copy link

@Gerke-W Gerke-W commented Apr 9, 2025

Description (*)

This pull request addresses a known issue in Magento Checkout where child products are not displayed correctly when the cart contains more than 20 products and pagination is enabled. the issue is that $_item->getHasChildren() returns NULL and $_item->getChilderen() returns NULL for configurable products when the cart is paginated.

To fix this, I've implemented the following changes:

  1. Added updateCollectionWithQuoteItems Method: This method iterates over the items in the collection and updates them with the corresponding quote items. It ensures that the correct items are displayed in the cart, even when pagination is active.

These changes ensure that $_item->getHasChildren() returns true for configurable products, and $_item->getChildren() returns the correct array of child items, regardless of pagination status. This resolves the issue described in #34507 and improves the reliability of the checkout process.

Fixed Issues (if relevant)

  1. Fixes $_item->getChildren() returns empty array for parent cart items when cart is paginated #34507

Related Pull Requests

35739

Manual testing scenarios (*)

  1. Add both configurable and non-configurable products to the cart.
  2. Print the $_item->getHasChildren() property in the Magento_Checkout/cart/item/default.phtml template.
  3. Observe the function output with and without pagination in the cart.

Expected result

The cart should behave as expected even when underlying code is calling for childeren of a products i.e. $_item->getHasChildren() and $_item->getChilderen().

image

Copy link

m2-assistant bot commented Apr 9, 2025

Hi @Gerke-W. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ 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 Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@Gerke-W
Copy link
Author

Gerke-W commented Apr 10, 2025

@magento run all tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Apr 15, 2025
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

$_item->getChildren() returns empty array for parent cart items when cart is paginated
2 participants