I'm debugging url rewrites in M2.

  • One can change the product url key in catalog/product/edit in the Search Engine Optimization tab
  • I'm looking at Magento\Catalog\Controller\Adminhtml\Product\Save::execute yet I see nothing related to url keys.

  • Q: Who is in charge with of url_rewrites CURD? Where are url_rewrites handled during product update?

2 Answers 2


Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::getUrlPath() Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::getUrlPath()


There is two way to change product URL one is create plugin

of Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::getUrlPath()

Create a Observer for product save after event

create events.xml at below path


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="catalog_product_save_after">
        <observer name="test_name" instance="YOUR_NAMESPACE\YOUR_MODULENAME\Observer\Productsaveafter" />

create Productsaveafter.php at below path




use Magento\Framework\Event\ObserverInterface;

class Productsaveafter implements ObserverInterface
    public function execute(\Magento\Framework\Event\Observer $observer)
        $_product = $observer->getProduct();  // you will get product object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.