Inside an observer, I need to get the URL to edit the product in the Admin Area.

Using the following code :


I get an URL which is not working (and it also have the session value)


Which one is the best way to fetch the product URL of the Admin Area?

1 Answer 1


To get the Edit Product url (catalog/product/edit), you can use the Magento\Backend\Helper\Data::getUrl function.

Include it in your constructor:

public function __contruct(\Magento\Backend\Helper\Data $backendHelper)
    $this->backendHelper = $backendHelper;

Then call getUrl:

$productEditUrl = $this->backendHelper->getUrl(
    ['id' => 1]

This will get you the product edit url for the admin for the product with id 1.


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.