Jump to content

Update specific product image with webservices


Sevarf2

Recommended Posts

Hello, I'm trying to update / add a product image in a specific position, or declination as prestashop says.
I'm able to add an image but I can't add the declination id in the request and presta adds the image at the end leaving the other ids empty, if any....solutions? Thanks

I already tried to add the imge id at the end of the url like so "domain.com/api/images/products/productid/imageid/" but it doesn't work

this is my code for adding an image

 

function psProductsImageAdd($store,$productId,$image,$mime='image/jpg'){
        
        $apiUrlImage = $store->shopurl.'/api/images/products/'.$productId.'/';

        $args['image'] = new CurlFile($image, $mime);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
        curl_setopt($ch, CURLOPT_URL, $apiUrlImage);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_USERPWD, $store->apikey.':');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
        $result = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        return $httpCode;
        
    }

 

Edited by Sevarf2 (see edit history)
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...