简体   繁体   中英

WooCommerce Rest API - woocommerce_api_invalid_remote_product_image

I am currently using this API: https://github.com/kloon/WooCommerce-REST-API-Client-Library to automatically keep my products upto date from several different data feeds.

I have been using the package for a few weeks now but since upgrading my WooCommerce version to 2.4.7 I have been having issues.

I use the feed to create products from several feeds but since the update I am getting an error when trying to upload images: woocommerce_api_invalid_remote_product_image

The code has not changed and has worked for several weeks before the upgrade, images were automatically synced with the media section.

Below is the structure of the data I use which is passed into the following line: print_r($client->products->create($data));

$data = Array ( [product] => Array ( [title] => Title1 [type] => external [sku] => 369100007 [product_url] => valiurl [regular_price] => 999.99 [sale_price] => [description] => Description [categories] => Array ( [0] => Main Cat [1] => Sub Cat ) [images] => Array ( [src] => validimageurl [position] => 0 ) [tags] => Array ( [0] => Tag1) [attributes] => Array ( [0] => Array ( [name] => Color [slug] => color [position] => 0 [visible] => 1 [options] => ) ) ) )

I have changed some of the data above to keep it short. The images don't seem to be uploading (which is throwing out the error) and there is also an issue with Categories and Tags not being set. Once again to reiterate I have not changed any code since the update.

Have tested the following data structure against WooCommerce 2.4.7 and it works fine

$client->products->create( array( 
        'title' => 'External',
        'sku' => 'ext001', 
        'type' => 'external', 
        'regular_price' => '100',
        'product_url' => 'http://www.example.com',
        'description' => 'This is external product', 
        'sale_price' => '80', 
        'weight' => '15',
        'images' => Array ( '0' => Array( 'src' => 'http://placehold.it/150x150.jpg', 'title' => '21', 'position' => '0' ) ),       
        'description'=>'This is the description',
        'categories' => Array( 32, 30 ),
        'tags' => Array( 82 ),
        'short_description'=>'Short Description',
        'enable_html_short_description' => true,
        'attributes' => array( array( 'name'=>'color','slug'=>'color','type'=>'text','options'=> array('red','white'),'variation'=>'false') ),
       )  ); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM