Skip to content

fix(catalog): align getChildren() method signature with caller and Flat implementation#40506

Open
lbajsarowicz wants to merge 1 commit intomagento:2.4-developfrom
lbajsarowicz:fix/40257-category-getchildren-params
Open

fix(catalog): align getChildren() method signature with caller and Flat implementation#40506
lbajsarowicz wants to merge 1 commit intomagento:2.4-developfrom
lbajsarowicz:fix/40257-category-getchildren-params

Conversation

@lbajsarowicz
Copy link
Contributor

@lbajsarowicz lbajsarowicz commented Feb 4, 2026

Description (*)

Align ResourceModel\Category::getChildren() method signature with:

  • The Category model's call which passes 4 arguments
  • The ResourceModel\Category\Flat::getChildren() signature

Problem: The Category model calls $this->getResource()->getChildren($this, $recursive, $isActive, $sortByPosition) but the resource model only accepted 2 parameters. This caused extra arguments to be silently ignored and inconsistent behavior between flat and non-flat catalog modes.

Solution: Add $isActive and $sortByPosition parameters to match the Flat implementation. Default values maintain full backward compatibility.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Extra arguments passed to getChildren() cause inconsistent plugin behavior #40257

Manual testing scenarios (*)

  1. Navigate to Admin > Catalog > Categories
  2. Expand a parent category with child categories
  3. Verify the category tree displays correctly with all children
  4. Test with both flat catalog enabled and disabled

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

⭐ Support my work

Do you like the fix? Remember to react with "👍🏻" to get it merged faster,
Then Sponsor me on Github so I can spend more time on fixing issues like this one.

Learn more at https://github.com/sponsors/lbajsarowicz

…at implementation

Add $isActive and $sortByPosition parameters to
ResourceModel\Category::getChildren() to match:
- The Category model's call which passes 4 arguments
- The ResourceModel\Category\Flat::getChildren() signature

Previously, the model passed 4 arguments but the resource model only
accepted 2, causing the extra arguments to be silently ignored. This
created inconsistent behavior between flat and non-flat catalog modes
and caused confusion for plugin developers.

The default values maintain backward compatibility:
- $isActive = true (same as previous implicit behavior)
- $sortByPosition = false (no change in default behavior)

Fixes magento#40257
@m2-assistant
Copy link

m2-assistant bot commented Feb 4, 2026

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

@lbajsarowicz
Copy link
Contributor Author

@magento run all tests

@lbajsarowicz
Copy link
Contributor Author

@magento run Functional Tests B2B, Functional Tests EE, Functional Tests CE

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra arguments passed to getChildren() cause inconsistent plugin behavior

1 participant