Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting Product images #82

Open
eMatsiyana opened this issue Nov 20, 2013 · 3 comments
Open

Inserting Product images #82

eMatsiyana opened this issue Nov 20, 2013 · 3 comments

Comments

@eMatsiyana
Copy link

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
Copy link
Contributor

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
Copy link

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

@acidburner
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants