From c72c2f06b85eb7eab652a9c53f4ecba00b913c3d Mon Sep 17 00:00:00 2001 From: victorfreitas Date: Tue, 3 Oct 2017 10:17:09 -0300 Subject: [PATCH] Save postmeta attachment image reference on import of products via API rest. --- includes/api/class-wc-rest-products-controller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index fda1c96d106..1e4842f9436 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -1078,6 +1078,11 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller { if ( ! empty( $image['name'] ) ) { wp_update_post( array( 'ID' => $attachment_id, 'post_title' => $image['name'] ) ); } + + // Set for future reference + if ( ! empty( $image['src'] ) ) { + update_post_meta( $attachment_id, '_wc_attachment_source', esc_url_raw( $image['src'] ) ); + } } $product->set_gallery_image_ids( $gallery );