\Magento\Framework\App\FrontController::dispatch
\Magento\Framework\App\Action\Action::dispatch
\Magento\Catalog\Controller\Adminhtml\Category\Save::execute
Category Url rewrite
This particular place in Magento has some intricaties that are daunting for the developers and critical for the Marketing team.
A category can be setup with different url rewrite for different stores. The critical part consists in validating that the canonical url matches the url key for each categories in the category path.
Let’s take a category Category 1 (url key cat1) and a first child category for it Category 12 (url key cat12)
When both categories are setup on the global scope, we have the path category is cat1/cat12
Let’s explore the use cases for the url path when the scope category data are modified:
use case 1: the category url key is set for the global scope and the category url key is not set for either of the default store or custom store: only store 0 has a url key
global scope: store id = 0, url path: cat1/cat12
use case 2: the child category uses a global url key for the default store and uses a custom url key (cat12_2) for the custom store (store 2)
global scope: store id = 0, url path: cat1/cat12
custom store scope: store id = 2, url path: cat1/cat12_2
use case 3: the child category uses a custom url key for the default store (cat12_1) and uses a global url key for the custom store (store 2)
global scope: store id = 0, url path: cat1/cat12
default store scope: store id = 1, url path: cat1/cat12_1
use case 4: the child category uses a custom url key (cat12_1) for the default store and uses a custom url key (cat12_2) for the custom store (store 2)
global scope: store id = 0, url path: cat1/cat12
default store scope: store id = 1, url path: cat1/cat12_1
custom store scope: store id = 2, url path: cat1/cat12_2