Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Api: Documenting Image Object

 

Posted 25 June 2019 - 09:46 PM #1

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]



 

Posted 27 June 2019 - 07:37 PM #2

In reviewing the posts here further, I found the answer:

$main_pair = (object)(['detailed'=>(object)['image_path'=>$http_path]]);