Is it possible to add in an automatic redirect for when you delete a product from Magento?

E.g. If you delete a product that is in Category A, it will then automatically redirect to the Category A page when someone visits the URL of the product that has been deleted?

2 Answers 2


A product can be assigned to multiple categories, so you won't be able to fall back to Category A unless you specify in some way that that Category A is the correct destination.

Also, if you actually delete the product, you will be reliant on a Custom Redirect to handle requests to the old product url. For the redirect to be "automatic", a Custom Redirect would have to be created programmatically when the product was deleted, e.g. by an observer.

  • what if the products are only ever assigned to one category? Would there be a way to implement this?
    – user280492
    May 1, 2018 at 10:45

Take a look at this table core_url_rewrite. Try to look for the deleted product in the column id_path. If found, you can edit the value in target_path to point to the category you want, which is the URI of the category, eg catalog/category/view/id/9. If not found, and if you know the URI of the deleted product page, you can add an entry to the table by setting the old URI of the product in the column request_path and set the redirect in the column target_path.

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.