How to Get All Product URLs in Magento 2

How to Get All Product URLs in Magento 2

The admin can create six different types of products in Magento 2 store and each time a product is created, a unique URL is created for that product page.

Now, when you are working with HTML sitemap in your Magento 2 store, you might need the list of all these product URLs. Manually creating this list is a tedious process and prone to error.

Hence, I have posted a programmatic solution to get all product URLs in Magento 2 store.

Using this solution, one can get all product URLs and use them while updating the product data, creating HTML sitemap for navigation purpose or simply track the URLs of the store.

Also, a store owner may maintain and update such a product list from time to time to monitor the store expansion and product performance.

In all such scenarios, follow the programmatic solution given below to get all product URLs in Magento 2.

Note: You might also find the solution to get all category URLs in Magento 2 helpful if you are creating HTML sitemap and landed to my post!

Steps to Get All Product URLs in Magento 2

  1. Create registration.php at Vendor/Module.
  2. Create module.xml at Vendor/Module/etc.
  3. Create ProductPageUrls.php at Vendor/Module/Helper.

That’s it.

If you have any doubts regarding this post, just mention them in the Comments section below.

I would be happy to help.

Feel free to share the solution with Magento Community via social media.

Thank You.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 16 Reviews)

Yash is a Magento Developer at Meetanshi. He loves playing computer games and watching action movies. For brain exercise, he likes to play Chess.

Leave a reply:

Your email address will not be published.