Uncategorized Comments Off





  • Load all the full size images to the location ../wp-content/uploads/YEAR/MONTH/ folder YEAR is the current year and MONTH is the current month and is always 2 digits eg Feb = 02
  • Create a CSV file that looks something like :-SKU, Name, Price, Image001, Shoe, 100, 2011/04/1.jpg

    002, Hat, 20, 2011/04/2.jpg

    003, Sock, 23, 2011/04/3.jpg

    The string before the image name is the same and should reflect the YEAR/MONTH/ that was used in step 1. to upload the images to.

  • Open wp-e-commerce/wpsc-admin/includes/settings-pages/import.php
  • Find the line :-<option value=’name’><?php _e(‘Product Name’, ‘wpsc’); ?></option> and add the following line to the end of the blocks defintions :-<option value=’imagename’><?php _e(‘Image’, ‘wpsc’); ?></</option>
  • Next find the line (maybe #162):-wp_set_object_terms( $product_id , array( (int)$_POST[‘category’] ) , ‘wpsc_product_categoryand add the following directly underneath it:-

    if ( $cvs_data2[‘imagename’][$i] != ” ){

    //need the full location of the file so first we get the upload directory

    $upload_dir = wp_upload_dir();

    //now build the file location

    $filename = $upload_dir[‘baseurl’] . ‘/’ . trim( $cvs_data2[‘imagename’][$i] );

    //we also need to store just the file location from within the upload directory

    $metafilename = trim( $cvs_data2[‘imagename’][$i] );

    //establish filetype

    $wp_filetype = wp_check_filetype(basename($filename), null );

    //build our attachment array

    $attachment = array(

    ‘post_mime_type’ => $wp_filetype[‘type’],

    ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($filename)),

    ‘post_content’ => ”,

    ‘post_status’ => ‘inherit’


    //insert attachment data into WP IMPORTANT – we need to use $metafilename here NOT the filename with the full URL

    $attach_id = wp_insert_attachment( $attachment, $metafilename, $product_id );

    // you must first include the image.php file

    // for the function wp_generate_attachment_metadata() to work

    require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);

    //generate metadata

    $attach_data = wp_generate_attachment_metadata( $attach_id, $metafilename );

    wp_update_attachment_metadata( $attach_id, $attach_data );



  • Go to Dashboard>Settings>Store>Import and enter the name of the import.csv file with the information in the click Import
  • Select the Product Status to be Published and then associate the headings of the csv file with the values in the drop down boxes.
  • Next select the category that they will all go into and click Import.
  • All the data and the images will then be imported into the WP e-Commerce site.




Back to Top

x Shield Logo
This Site Is Protected By
The Shield →