I installed Magento 2.1.3 enterprise edition. I created new category and a new product. It shows frontend correctly with given url_key under SEO tab. Now I need to change the url_key. When I change, It doesn't reflect in frontend, old url_key is used to display the product. But it displays updated value in back-end.


I tried to update attributes in catalog grid actions option. But nothing happen.


If I change url_key and save manually, url_rewrite table creates the new url with 301 permanent redirection. But when I update url_key via script it's not working.

So please help me to solve this issue.

Thanks in advance.

1 Answer 1


This solve for CE, it can doesn't approach for EE.

If you modify url_key attribute in your own script directly (without saving product), you need to add code for the rewrite creating manually.

Magento add this functionality after saving product in observer:


public function execute(\Magento\Framework\Event\Observer $observer){        
    $product = $observer->getEvent()->getProduct();

    if ($product->dataHasChangedFor('url_key')
        || $product->getIsChangedCategories()
        || $product->getIsChangedWebsites()
        || $product->dataHasChangedFor('visibility')
    ) {
            UrlRewrite::ENTITY_ID => $product->getId(),
            UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
            UrlRewrite::REDIRECT_TYPE => 0,
            UrlRewrite::STORE_ID => $product->getStoreId()

        if ($product->isVisibleInSiteVisibility()) {

You should add this code to your own script with some changes, of course.

  • I saved product manually with different url_key, but this also not updated in url_rewrite table. Commented Mar 16, 2017 at 10:01

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.