bigcommerce / bigcommerce-api-php

Connect PHP applications with the Bigcommerce Platform
https://developer.bigcommerce.com
MIT License
144 stars 185 forks source link

Inserting Product images #82

Open eMatsiyana opened 11 years ago

eMatsiyana commented 11 years ago

I have been trying to upload Product images through the API without Success. The Code below states that, the images field can not be writen to and i get the 400 error..

$fields = array( "product_id" => "$prodid", "images" => array("image_file" => "$image")); $apiresult=BigCommerce_Api::updateProduct($prodid, $fields);

So i tried the code below.

$image = new Bigcommerce_Api_ProductImage(); $image->product_id = $prodid; $image->image_file = $image; // etc.. $image->create();

Which then says the Class 'ProductImage' not found.

Is this a namespace issue?

zackkatz commented 10 years ago

This is completely untested, but try adding this to a line at the top of your PHP file:

use Bigcommerce\Api\Resource\ProductImage as ProductImage;

caovillanueva commented 10 years ago

Whats the correct way to upload/insert images to product. Is possible through this api???

acidburner commented 7 years ago

$image = $fields["images"]; BigCommerce_Api::createResource( '/products/' . $productId . '/images', $image );

As per the API, images, among other properties, are Read Only, and cannot be created with the Product Resource. You simply need to specify these Read-Only Resources as their own API calls.