Import download attachment from woocommerce product

Here is the solution i’ve found :
in wordpress-importer plugin function process_posts :

// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
$postdata['upload_date'] = $post['post_date'];
if ( isset( $post['postmeta'] ) ) {
    foreach( $post['postmeta'] as $meta ) {
        if ( $meta['key'] == '_wp_attached_file' ) {
            if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches) )
            {
                $postdata['upload_date'] = $matches[0];
                $postdata['woocommerce'] = false;
            }
            else if ( preg_match( '%^(woocommerce_uploads)/([0-9]{4}/[0-9]{2})%', $meta['value'], $matches ) ) {
                $postdata['upload_date'] = $matches[2];
                $postdata['woocommerce'] = true;
            }
            break;
        }
    }
}

(this is the part where wordpress try to grab the upload date using the name of the directory – with woocommerce_uploads structute it will failed)

in wordpress-importer plugin function fetch_remote_file :

function fetch_remote_file( $url, $post ) {
        // extract the file name and extension from the url
        $file_name = basename( $url );

        global $wp_filter;
        if ( isset($wp_filter['pre_option_upload_path']) ) {
            remove_filter( 'pre_option_upload_path', 'woocommerce_path_upload' );
        }       

        if ( $post['woocommerce'] == true ) {
            add_filter( 'pre_option_upload_path', 'woocommerce_path_upload' );
        }

        $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );

(this is the part before uploading file we add a path before the upload path if it’s woocommerce file)

function woocommerce_path_upload () { return 'wp-content/uploads/woocommerce_uploads'; }

(the function uses in filter to correct the path)

And finally in wordpress core wp-includes/functions.php set $refresh_cache to true (default is false) :

function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = true ) {

(if you don’t modify that wordpress keep in cache the upload path and don’t check it on each file in our situation we need to check it everytime)

pay attention this is modification you do only during the migration after that reverse it