Skip to main content

URL reWrite

How Magento2 format the product URL

I have looked at almost 100 articles to know how Magento format the URL without any success and finally I found it and it was really so easy , here is the quick way to see it using object manager

Note: please consider to use the dependency injection

 

$_productloader = $objectManager->get('\Magento\Catalog\Model\ProductFactory');
$product =  $_productloader->create()->load(1);


echo  $product->formatUrlKey({Your text here});

 

in this way Magento will give you the correct URL which will be used