Jump to content



Member Since 29 May 2014
Offline Last Active Nov 12 2019 06:41 PM

Topics I've Started

Api: Documenting Image Object

25 June 2019 - 09:46 PM

I'm using the CS-Cart API at https://github.com/d...stvan/cscartapi(thanks drahos.istvan for making this just a bit easier)  to create new products (https://docs.cs-cart....html#main-pair). The CS-Cart API documentation is a bit skimpy, but I'm successfully adding products like so:


$main_pair = ['http_image_path'=>$image_url, 'image_path'=>$image_url, 'alt'=>$alt_text];

$data = ['product'=>$product_name, 'main_category'=>$toplevel_category_id, 'category_ids'=>$subcategory_id, 'price'=>50.00, 'status'=>'A', 'amount'=>10, 'free_shipping'=>'Y', 'full_description'=>$description, 'meta_keywords'=>join(', ', $keywords), 'search_words'=>join(', ', $keywords), 'product_code'=>$product_code, 'main_pair'=>$main_pair];
$product = $cscartapi->create("products", $data);


Since that doesn't work, I've also tried the approach of passing the 'detailed' object, but the documentation is not clear on exactly what that means (there's a seemingly orphaned reference to "object (content explained below)"). I've naively attempted to base64_encode the image data and pass it that way, but it doesn't work.


Is it, in fact, possible to assign a product image using the API? What format should the "object" take and/or am I making an obvious mistake with respect to the main_pair array (the simpler approach I'd prefer)?


[To moderator: this would ideally be posted to the Developer thread, but I am unable to post there]