Fabien Papet Fabien Papet - 5 months ago 373
PHP Question

Get product URL using Prestashop API

I have two stores using Prestashop. I would like to import a products URLs list from the first to the second.

I can access to the product list by using

http://example.com/api/products


I can also access to the product information by using

http://example.com/api/products/{ProductID}


By this way I can access to all products data but I can't find product URL.

Is there a way to retrieve a product URL from Prestashop ?

Answer

You can generate the product URL from the product ID:

$productUrl = 'http://mydomain.com/index.php?controller=product&id_product=' . $productId;

If Friendly URL is turned on then the URL will be rewritten.