Repository navigation
Export menu category links as url_path - #15
Merged
Merged
Conversation
added 2 commits
August 19, 2026 11:48
A menu addresses a CMS page by identifier and a product by SKU, both of which mean the same thing on every install. A category link was the exception: it stores the entity id, so an exported menu pointed at whatever category held that id on the target. CategoryLinkMapper swaps the id for url_path on export and back on import, covering both a category link and the category_ids list of hyva_menu_category_tree. url_path rather than name or url_key. Names collide freely, and Magento only enforces url_key uniqueness between siblings, so two branches can each hold "envelopes". url_path is the concatenation of the ancestor url keys, so it is unique by construction and still readable in a diff. Paths are read at the default store scope, which is what every store inherits unless overridden. Anything that does not resolve is reported and left as it stands, matching how a missing block or theme is already handled: the import completes, and the warning says what will not render. A category tree list is rewritten whole or not at all, so a partial failure cannot silently drop entries. Menus only. Pages and blocks can carry the same links, but they keep the behaviour they shipped with until that is asked for.
Setting url_path explicitly does not stick: the url path autogenerator derives it from the category name on save, so the fixture category came back as category-1 and the assertion compared against a value that never existed.
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.
Follow-up to #14. A menu addresses a CMS page by identifier and a product by SKU, both portable. A category link was the exception: it stores the entity id, so an exported menu pointed at whatever category held that id on the target.
CategoryLinkMapperswaps the id forurl_pathon export and back on import, covering both acategorylink and thecategory_idslist ofhyva_menu_category_tree.Why url_path
Measured on a real 288-category catalog:
nameurl_keyurl_pathnamecollides 41 times, so it is unusable.url_keyis unique on that catalog by luck — Magento only enforces it between siblings, so two branches can each holdenvelopes.url_pathis the concatenation of the ancestor url keys, unique by construction and still readable in a diff.Paths are read at the default store scope, which is what every store inherits unless overridden.
Failure handling
Anything that does not resolve is reported and left as it stands, matching how a missing block or theme is already handled: the import completes and the warning says what will not render.
A category tree list is rewritten whole or not at all, so a partial failure cannot silently drop entries from a tree.
Scope
Menus only. Pages and blocks can carry the same links, but they keep the behaviour they shipped with until that is asked for.
Verification
Against a real install, with a category link (id 147) and a category tree (
148,149) added to a live menu:product-category/amsive-miamisburgandproduct-category/state-wisconsin-employee-trust,product-category/state-wisconsin-uw-green-bay147and148,149category path "product-category/does-not-exist-here" does not exist on this install, left as it isand the import completedIntegration tests cover the round trip for a link and for a tree, an unknown path, a non-category link passing through untouched, and empty or non-json content.