Jump to content

webservice - add image with alt to product


Recommended Posts


I create a script to import add product in prestashop 1.7.

I success to add image to product via /api/images/products/<id_product> but I want to specify alt for once image I add..

How to get image id after added via /api/images/products/<id_product> ?? this request don't return image id...

My code (php) :

function ajouter_image_produit($webService,$id_ps_produit,$url_image) {
	$urlImage = PS_SHOP_PATH.'/api/images/products/'.$id_ps_produit.'/';
	$image_mime = image_type_to_mime_type(exif_imagetype($url_image));
	$args['image'] = new CurlFile($url_image, $image_mime);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $urlImage);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':');
	curl_setopt($ch, CURLOPT_POSTFIELDS, $args); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$result = curl_exec($ch);

Thanks a lot,

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