Jump to content

Update specific product image with webservices


Sevarf2
 Share

Recommended Posts

Posted (edited)

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)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More