Magento 2 Certified Associate Developer — Question 3

A client has asked you to include category url keys in product URLs.
How is this done?

Answer options

Correct answer: D

Explanation

The correct approach is to create an after plugin on \Magento\UrlRewrite\Controller\Router::generateRewrite, as this allows for the modification of URL generation to include category keys. Option A is incorrect because observers do not directly influence URL generation in this context. Option B is not valid as it is indeed possible to include category URL keys. Option C does not provide the necessary method to implement this requirement.