Merge pull request #17037 from victorfreitas/master

Save postmeta attachment image reference on import of products via AP rest.
This commit is contained in:
Claudio Sanches 2017-10-03 19:32:27 -03:00 committed by GitHub
commit e6710258d2
1 changed files with 5 additions and 0 deletions

View File

@ -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 the image source if present, 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 );