Jump to content

Prestashop Webservice / Get Images


soduno

Recommended Posts

I am trying to get images for a product in Prestashop Webservice. Currently I've managed to get description, price, title etc. But when I try to get the images it only gives me the ID of the images, not the complete url. If I go to http://your-url.com/api/images/products/XproductidX I can with no problem get the images, but doing this through the webservice, is apparently a bit more complicated.

 

Here is my code so far: 

$opt = array(
			'resource' => 'products',
			'display' => 'full',
			'limit' => 5,
		);
		$xml = $webService->get($opt);
		$resources = $xml->children()->children();
		
		foreach($resources as $product){
			if($product->id[0] == 286){

				$title = $product->meta_title->language;
				$description = $product->meta_description->language;
				$description_short = $product->description_short;
				$quantity = $product->quantity;
				$price = $product->price;
				$wholesale_price = $product->wholesale_price;

				$images = $product->associations->images;
				print_r($images);
			}
		}

With that print_r at the bottom, I am able to receive following:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [nodeType] => image
            [api] => images
        )

    [image] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [id] => 34
                )

            [1] => SimpleXMLElement Object
                (
                    [id] => 35
                )

            [2] => SimpleXMLElement Object
                (
                    [id] => 36
                )

            [3] => SimpleXMLElement Object
                (
                    [id] => 37
                )

            [4] => SimpleXMLElement Object
                (
                    [id] => 38
                )

            [5] => SimpleXMLElement Object
                (
                    [id] => 39
                )

            [6] => SimpleXMLElement Object
                (
                    [id] => 40
                )

        )

)

This gives me the ID of the images. Is there any way to get the full url, or at least get image url through an resource?

Perhaps I am doing this the wrong way? :-)

 

Regards, Simon

Edited by soduno (see edit history)
Link to comment
Share on other sites

  • 3 years later...

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...