How to update and override product image via RESTful API?
-
Hello!
I am using the RESTful API to update (automated) periodically hundred of products in my woocommerce (still 3.9.3) store. Therefor I use the
products/<id>
endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-productThis works pretty fine but I found now out that
*woocommerce uploads a new image every time when a product update is done,
*the old image of the product remains in the wp-uploads folder,
*my webspace reaches its maximum after a while and
*this happens even if the referenced image is exactly the same, than before.I will try out a cleanup plug-in to get over this issue. Nevertheless I would like to ask:
How to update/override product image via RESTful API?
-
This topic was modified 4 years, 11 months ago by
edeviser.
-
This topic was modified 4 years, 11 months ago by
-
Hi there. This definitely doesn’t sound right! Do you have a log of the exact call that is being sent to WooCommerce via the API when you update the product image?
Also, can you send us your system status report? You can find that by going to WooCommerce > Status in your dashboard, then clicking “Get system report,” then “Copy for support.”
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.
Hey Amanda and Austin M, sorry for the big delay. I am having some other (bigger) trouble. I would like to provide a detailed minimal example showing the issue. This will take more than fife minutes for me. I’ll come back to this issue back within next week.
Thank’s again for you reply and best regards,
eDeviser.So here we are. I made a minimalist example updating one product.
First I made a listing of recently uploaded files in
wp-content/uploads/2020/05
and stored that listing in a file.Then I updated one product with this call and echoed to the commandline the endpoint and the data which are passed to the my PUT method:
====ENDPOINT: products/25699 ====DATA: {"regular_price":"304.11","sku":"payton_used","name":"Motorola Moto X4","images":[{"src":"https:\/\/lineageos-device-finder.org\/wp-content\/uploads\/data-provider\/payton.png"}],"reviews_allowed":true}
After that I made again a listing of uploaded files and stored it to another file. The diff of the two files looks as this:
May 10 22:39 payton-26-100x100.png May 10 22:39 payton-26-300x300.png May 10 22:39 payton-26-324x324.png May 10 22:39 payton-26-416x416.png May 10 22:39 payton-26-80x80.png May 10 22:39 payton-26.png
As you can see WooCommerce created six new
png
-files with a26
as postfix in the name. If I would trigger the same update with the same data and endpoint again, WooCommerce would add again six newpng
-files with a27
as postfix.And here is the status report. I found no option for attachements, so checkout this paste:
### WordPress Environment ### WordPress address (URL): https://lineageos-device-finder.org Site address (URL): https://lineageos-device-finder.org WC Version: 3.9.3 REST API Version: ? 1.0.7 Log Directory Writable: ? WP Version: ? 5.3.3 - There is a newer version of WordPress available (5.4.1) WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ? Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.41 (Unix) PHP Version: 7.3.16 PHP Post Max Size: 76 MB PHP Time Limit: 240 PHP Max Input Vars: 4000 cURL Version: 7.54.0 OpenSSL/1.0.2k SUHOSIN Installed: – MySQL Version: 5.6.42-log Max Upload Size: 64 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 3.9.3 WC Database Prefix: wp_ Total Database Size: 77.33MB Database Data Size: 60.63MB Database Index Size: 16.70MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_Aalb_Asin_Response: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_aal_products: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_aal_request_cache: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_amz_assets: Data: 0.03MB + Index: 0.01MB + Engine MyISAM wp_amz_cross_sell: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_amz_products: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_amz_queue: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_amz_report_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_amz_search: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_atkp_additionaloffers: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_berocket_termmeta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_childthemewp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 1.02MB + Index: 0.67MB + Engine InnoDB wp_duplicator_packages: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_layerslider: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_layerslider_revisions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_mclean_refs: Data: 0.06MB + Index: 0.00MB + Engine InnoDB wp_mclean_scan: Data: 0.33MB + Index: 0.09MB + Engine InnoDB wp_options: Data: 4.06MB + Index: 0.31MB + Engine InnoDB wp_postmeta: Data: 35.02MB + Index: 6.03MB + Engine InnoDB wp_posts: Data: 11.02MB + Index: 6.28MB + Engine InnoDB wp_statistics_exclusions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_statistics_historical: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_statistics_pages: Data: 0.06MB + Index: 0.19MB + Engine InnoDB wp_statistics_search: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_statistics_useronline: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_statistics_visit: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_statistics_visitor: Data: 0.23MB + Index: 0.45MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.16MB + Index: 0.16MB + Engine InnoDB wp_term_relationships: Data: 3.02MB + Index: 1.05MB + Engine InnoDB wp_term_taxonomy: Data: 0.14MB + Index: 0.14MB + Engine InnoDB wp_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.09MB + Index: 0.16MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woof_query_cache: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woof_stat_buffer: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woof_stat_tmp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_yoast_seo_links: Data: 1.02MB + Index: 0.05MB + Engine InnoDB wp_yoast_seo_meta: Data: 3.38MB + Index: 0.00MB + Engine InnoDB ### Post Type Counts ### aal_button: 1 atkp_shop: 1 attachment: 3803 avia_framework_post: 39 br_filters_group: 1 br_labels: 4 br_product_filter: 8 customize_changeset: 1 custom_css: 4 elementor_library: 1 nav_menu_item: 10 page: 8 post: 1 product: 568 revision: 3 scheduled-action: 1314 wpplugin_don_button: 3 wpplugin_don_order: 3 wp_block: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (14) ### WooCommerce Advanced Product Labels: by BeRocket – 1.1.16.4 Autoptimize: by Frank Goossens (futtta) – 2.6.2 Duplicate Post: by Enrico Battocchi – 3.2.4 Duplicator: by Snap Creek – 1.3.30 PayPal Donation: by Scott Paterson – 1.2.9 Site Kit by Google: by Google – 1.8.0 Media Cleaner: by Jordy Meow – 5.6.2 WooCommerce External Product New Tab: by Stuart Duff – 1.0.3 WooCommerce Admin: by WooCommerce – 0.26.1 WOOF - WooCommerce Products Filter: by realmag777 – 2.2.3 – Not tested with the active version of WooCommerce WooCommerce: by Automattic – 3.9.3 – 4.1.0 is available Yoast SEO: by Team Yoast – 13.5 WP-Optimize - Clean, Compress, Cache: by David Anderson Ruhani Rabin Team Updraft – 3.0.19 WP Statistics: by VeronaLabs – 12.6.13 ### Inactive Plugins (1) ### WP Config File Editor: by AHMeD SAiD – 1.7 ### Dropin Plugins (1) ### advanced-cache.php: advanced-cache.php ### Settings ### API Enabled: ? Force SSL: – Currency: USD ($) Currency Position: left Thousand Separator: . Decimal Separator: , Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – ### WC Pages ### Shop base: ? Page not set Cart: ? Page not set Checkout: ? Page not set My account: ? Page not set Terms and conditions: #687 - /site-notice/ ### Theme ### Name: Storefront Version: 2.5.3 – 2.5.6 is available Author URL: https://woocommerce.com/ Child Theme: ? – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ? ### Templates ### Overrides: – ### Action Scheduler ### Complete: 1,312 Oldest: 2020-04-09 22:31:16 +0000 Newest: 2020-05-10 21:28:02 +0000 Pending: 2 Oldest: 2020-05-10 22:28:02 +0000 Newest: 2020-05-10 22:28:02 +0000 Canceled: 0 Oldest: – Newest: – In-progress: 0 Oldest: – Newest: – Failed: 0 Oldest: – Newest: –
- The topic ‘How to update and override product image via RESTful API?’ is closed to new replies.