Use canonical category id_path equality in URL rewrite category joins - #5663
Merged
addison74 merged 8 commits intoJul 21, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines category URL rewrite predicates by replacing broad id_path LIKE 'category/%' matching with a canonical “category id_path equals category/” condition to reduce unnecessary inner-loop scans during category URL rewrite joins.
Changes:
- Updated
Mage_Catalog_Helper_Category_Url_Rewritejoin predicates to use canonical categoryid_pathequality. - Updated
Mage_Core_Model_Resource_Url_Rewrite_Collection::filterAllByCategory()to use canonical categoryid_pathequality.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| app/code/core/Mage/Catalog/Helper/Category/Url/Rewrite.php | Replaces category id_path prefix matching with canonical equality in the helper’s URL rewrite joins. |
| app/code/core/Mage/Core/Model/Resource/Url/Rewrite/Collection.php | Changes the “all category rewrites” filter predicate from LIKE to canonical equality. |
Copilot AI
added a commit
that referenced
this pull request
Jul 11, 2026
…L rewrite CONCAT expressions Apply PR #5663 changes with proper quoting - replace LIKE 'category/%' with = CONCAT('category/', entity_id) for more precise category URL rewrite joins. Use double-quoted strings (not escaped single quotes) to satisfy Rector's SimplifyQuoteEscapeRector rule which was flagging the CI job failure.
Contributor
Author
|
Adopted #5681 changes |
theroch
approved these changes
Jul 19, 2026
addison74
approved these changes
Jul 20, 2026
|
loekvangool
deleted the
fix/category-url-rewrite-canonical-id-path-upstream
branch
July 21, 2026 14:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This changes category URL rewrite predicates from broad prefix matching to canonical equality:
id_path LIKE 'category/%'id_path = CONCAT('category/', category_id)Touched files:
app/code/core/Mage/Catalog/Helper/Category/Url/Rewrite.phpapp/code/core/Mage/Core/Model/Resource/Url/Rewrite/Collection.phpWhy
The broad prefix predicate can fan out inner-loop probes. In measured
ANALYZE FORMAT=JSONruns, the relevant probe dropped roughly from cost ~80 to ~2 (about 40x cheaper for that join probe pattern).Correctness / Risk
category_idandid_pathdisagree).Slow:
Optimized:
Recovery if inconsistency is found
Closes #5662