'Modify WooCommerce REST API product image upload

I have to create and update products via WooCommerce REST API, without image uploads to media library (only the image source is need to be stored, because they are hosted on another server).

In the wc-rest-functions.php there are 2 functions I want to override:

  • wc_rest_upload_image_from_url (line 67) and
  • wc_rest_set_uploaded_image_as_attachment (line 130)

which are called from the WC_REST_Products_Controller class from the set_product_images (line 228) method.

I have searched for actions or filters to achieve the desired result with no luck.

Is there any way to modify the functionality of image upload without edit the core WooCommerce files (somehow redeclare the functions, or replace the controller class with a custom one)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source