I have a site that needs to migrate from WP E-Commerce to WooCommerce.

I'm trying to use WP All Import Pro + WP All Import Woocommerce add on to do this.

I exported the WP E-Commerce products in an XML file, and imported the XML file into WooCommerce products using WP All Import.

It works fine, except I can't get the image URL from the XML file, there is only a thumbnail ID, which can't be used by the WP All Import Woocommerce add on (that I can see).

So, I'd love to be able to convert a list of thumbnail IDs into their image URL equivalents, and then swap these these URLs into the thumbnail ID field in the XML file.

How do I do this? Help appreciated.

  • Do you want the original image, or one of the resized versions (thumbnail, large, etc)? – Manny Fleurmond Sep 16 '15 at 15:07
  • Have you tried using other plugin to export? Can I get to see your xml file ? – Pooja Mistry Sep 23 '15 at 11:35

There are two functions you can use for this: wp_get_attachment_url to get the full sized image or wp_get_attachment_thumb_url, which gets the url of the thumbnail of that attachment. Either function takes the attachment id as the sole argument:

$attachment_id= 25;
//Get the full url
$url = wp_get_attachment_url( $attachment_id );
//get the thumbnail
$thumb = wp_get_attachment_thumb_url( $attachment_id );

Not sure how to get this done in your XML file, though, so this is a partial answer, but hopefully it sends you in the right direction.

| improve this answer | |
  • Hi Manny. Thanks for your answer. I am not a developer, but a designer. How could I run a PHP page to take all the thumbnail IDs, and spit out the full sized image URL, one per line? Thanks! – Steve Sep 17 '15 at 12:38
  • @steve When it runs the import there are actions you can listen for. When an action is triggered you can run a function to maniplate the data. wpallimport.com/documentation/developers/action-reference If that's out of scope, I'd just contact support. That's not a cheap plugin and I doubt you're the first to run into this. – Will Sep 24 '15 at 21:03

Hope this will probably solve your problem

<?php if ( $post->post_type == 'data-design' && $post->post_status == 'publish' ) {
    $attachments = get_posts( array(
        'post_type' => 'attachment',
        'posts_per_page' => -1,
        'post_parent' => $post->ID,
        'exclude'     => get_post_thumbnail_id()
    ) );

    if ( $attachments ) {
        foreach ( $attachments as $attachment ) {
            $class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
            $thumbimg = wp_get_attachment_link( $attachment->ID, 'thumbnail-size', true );
            echo '<li class="' . $class . ' data-design-thumbnail">' . $thumbimg . '</li>';


In the post type you could specify the required post type for which you need to fetch the images.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.