Jump to content

Get Image URL using Webservice


Recommended Posts

Hi guys

i create a plugin for our own platform to synchronise with any Prestashop. So the following should work in a general way, without changing or adding code in Prestashop:

How to get the image url of a product? currently i have this (using the PHP SDK from here PHP SDK😞

$opt['resource'] = 'products';
$opt['id'] = 1;

$xml = $webService->get($opt);
$resources = $xml->product->children();

$imageObject = $resources->id_default_image;

$productImage = $imageObject->attributes('xlink', true)->href;

But this only returns the permalink: http://prestashop17.bridev.com/api/images/products/1/1

But in order to import the image into our platform, i need the actual URL: http://prestashop17.bridev.com/2-large_default/hummingbird-printed-t-shirt.jpg

As far as i can see, only the permalink is in the returned XML. 

Does anybody know, how to get to the actual URL of an image?  or is it possible to form a url that gets the image? (like this: http://prestashop17.bridev.com/?getImage&images/products/1/1. i think i saw something link that....)

Thank you!

 

Link to comment
Share on other sites

one way to get the actual image is to request eg /api/images/products/1/1. and then file_put_contents the $request['response'].

but this is kind of cumbersome because there is no original filename and you have to extract the image type from the response header. i use Content-Sha1 in the header to name the file (that way i know if the file is already imported)

getting the image URL would still be more useful.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...