Importing Marketpress Images

Is there any way to import images along with products in Marketpress? If not, what is the best work-around to get images to be recognized with the proper products?

I've scoured the forums and it looks like TurboCVS and a couple of others have been mentioned, but the all appear dated. I don't mind spending a little to get this to work.

Any help for strategies importing images into Marketpress would be appreciated.

Regards,

Andy

  • aecnu
    • WP Unicorn

    Greetings Andy,

    Welcome to WPMU Dev!

    Though you did not mention it directly you must be referring to csv importing?

    The problem is here is that Market Press plugin uses the featured image as the rendered image which must be within the media library of the WordPress installation and there is no way to make that happen that I am aware of with the exception of manually uploading the image.

    Before me diving further into this, please advise if you are in fact referring to csv importing.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

  • andydahl
    • New Recruit

    Thanks and sorry for leaving that bit out. Yes, I'm trying to import products from a CSV file.

    From what you've written then, is this possible: If the images we're already in the media library, could I just reference them? If so, I would really appreciate it if you could give me instructions on how to do this, refer to images already in the media library.

    Thanks again!

    Andy

  • aecnu
    • WP Unicorn

    Greetings jimmysessions,

    Thank you for you feedback and concerns with this issue.

    This issue exists because it is an issue of Featured Images coded within the core of WordPress itself, therefore obviously not an easy issue to overcome nor directly related to Market Press.

    However, not only am I going to alert the developer to this obvious issue/problem but I am going to suggest a solution as well - basically making a feature request that for the csv importing there needs to be an option that the images can be rendered within Market Press as a URL bypassing the Featured Image feature of WordPress itself.

    Cheers, Joe

  • jimmysessions
    • WPMU DEV Initiate

    I don't think bypassing the featured image is a good idea. You are not getting my point I am saying it is possible to add a featured image programmatically.

    Let's look at the way magento product importer works:
    fist you upload all your images to the import dir of your site
    you then simply add the path to the image (relative to the import dir), to the product csv data
    then magento makes the association, moving the image, etc on import

    So for marketpress something similar could be done
    either user has to upload all images to media library or to an import dir
    then the importer would makes sure all the images are in media library
    *if you went the direction of putting images in an import dir then you could programmatically upload images via a url as explained here:
    http://theme.fm/2011/10/how-to-upload-media-via-url-programmatically-in-wordpress-2657/
    lastly you can set a featured image to post/product by simply setting the correct post meta data:

    update_post_meta($post_id, '_thumbnail_id', $image_id);

    By the way because marketpress does not have this feature I was forced to use woocommerce on a site, even though I prefer marketpress. I have said this many times but I think having a solid product imported is key for any ecomm software.

  • jimmysessions
    • WPMU DEV Initiate

    programmatically I left one step out; getting the image id from the image path.
    Each post, images and other attachments included, has an associated GUID that is its complete URL path. So, just pull the "post" with the associated GUID:

    SELECT id FROM wp_posts WHERE guid = 'http://myblogdomain.com/full-path-to-image.jpg'

    hope this helps

  • jimmysessions
    • WPMU DEV Initiate

    @Aaron thanks for the update, glad this is on the radar, however maybe @aecnu should stop telling people that this is impossible and people like me will stop trying to help solve the "impossible" problem. Remember, members are invested in these plugins success as well.

    Thanks for all your hard work.

  • andydahl
    • New Recruit

    Any idea of when this (important) feature will be implemented? I'm starting to regret my membership here, as the-most-important-feature of the-most-important-plugin is half-baked. It would be quite a job to import thousands of images, by hand, into Marketpress.

  • digitsoft
    • The Crimson Coder

    @andy - don't regret your membership - it's an amazing place with tons of valuable plugins, themes, and resources in the forums ready to help.

    @jimmy - because this IS an amazing community AND aecnu IS an amazing help is why he pulled in the developer. It was your tone...just take a little time to get to know everyone here.

    @aecnu - your comments that you sent to me the other day back at ya :wink:

  • aecnu
    • WP Unicorn

    Greetings jimmysessions,

    Thank you for your input and feedback it is appreciated.

    I also appreciate your input in that thread too and include the entire statement due to the fact your post with the link was significant in a way to possibly do this task:

    At this time it cannot be done I am afraid to report, featured image, not because of our programming but because of the underlying WordPress engine requires the featured image to be within the media gallery on the host. We are mashing brains to get around this somehow though it may take some time ro come up with coding to beat this major built in feature.

    I think you can accomplish this via media_sideload_image function

    checkout:
    http://theme.fm/2011/10/how-to-upload-media-via-url-programmatically-in-wordpress-2657/

    So much for a warm community welcome

    This is certainly a two way street and without a doubt your welcome here certainly stands from all the staff here at WPMU Dev and myself.

    Indeed though I never said it was impossible and the fact that I stated "mashing brains to get around this" clearly illustrates this fact.

    Forward :slight_smile:

    Cheers, Joe

  • Kyle
    • WPMU DEV Initiate

    ok is this fixed yet?

    marketpress has like 0 documentation. 24/7 support here = just community, which i have 2 questions open and no responses. i can't use this plugin if i have to manually enter each image, i have thousands.

    has this been resolved yet? if other plugins can do it, why can't yall?

    maybe its fixed and i dont know? help?

  • aecnu
    • WP Unicorn

    Greetings,

    This is awesome news Aaron, I remember not too long ago there was no facility at all for csv importing and as I see now the only thing missing to make this complete is of course the images.

    Thank you for your continued interest in making this feature a reality.

    Cheers, Joe

  • nick_gray
    • WPMU DEV Initiate

    I must give my clients are nice quick easy way to add products, the image is the key, with that missing means they must go into each product and add the image manually.
    I really like Market press, but if I can't solve this this bottle neck, or your team can't solve it, or tell me what other plug in i can use to crack this issue, I'm going to have to look at some other solution.

    my other issue is the shipping.
    I must be able to set shipping by region and then by weight. ( my customer is only selling ion NZ but in different areas and needs to charge a different weight by area)

    wp-ecommerce had a plug in for this called region-weight. IS there something similar i can use? If I have to write some php code i can do that. I have full control over my site as i also host it and have full control over the server.

  • aecnu
    • WP Unicorn

    Greetings nick_gray,

    Thank you for your input into this ticket, it is greatly appreciated.

    To the best of my knowledge the image factor and CSV importing has not yet been resolved in a production environment or more accurately release to date.

    I would like to also comment on our lead developers issue concerning time outs.

    This will be a major challenge because I have found that working with plugins like CSV Pig, which is no longer available to the public, that the timeout setting had to be jacked way up to successfully import csv files of any size, and it has to be higher then most hosts will allow.

    So I concur that it will be quite a challenge.

    The only way around this that I can foresee is if the image link can be used instead of actually importing the graphic and not being a coder I have no suggestions on how to implement this.

    Cheers, Joe

  • espsjurs
    • The Incredible Code Injector

    What about MarketPress Product Importer?

    They state to have fhe following features:

    Basic Product Data
    Featured Images
    Product Categories
    Product Tags
    Product SKU's
    Product Price
    Product Sale Price
    External Product Links

    I have not tested it yet, but will do soon..

  • espsjurs
    • The Incredible Code Injector

    Sorry, but this plugin was not an cvs importer, but uses 'CSVisual' to import csv into a temp table, then this plugin should be able to import to MarketPress..

    a bit complicated.. but might work..

    My guess is that only one of 1700 could figure it out and therefore liked it..

  • espsjurs
    • The Incredible Code Injector

    Hello there :slight_smile:

    In wp-admin/includes/media.php there is a function called media_sideload_image. This function can be used to upload images to the post (product) in the csv importer.

    Out of the box, it would add the image to the post's gallery, but if we make a copy of it and add some code it can also add as featured image.

    I made a copy of the function and called it 'eswd_media_sideloader()' and added some code as this:

    // Copy of media_sideload_image() function from media.php (wp-core)
    // - now with featured image
    //
    function eswd_media_sideloader($file, $post_id, $desc = null, $featured = null) {
    	if ( ! empty($file) ) {
    			// Download file to temp location
    			$tmp = download_url( $file );
    
    			// Set variables for storage
    			// fix file filename for query strings
    			preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
    			$file_array['name'] = basename($matches[0]);
    			$file_array['tmp_name'] = $tmp;
    
    			// If error storing temporarily, unlink
    			if ( is_wp_error( $tmp ) ) {
    					@unlink($file_array['tmp_name']);
    					$file_array['tmp_name'] = '';
    			}
    
    			// do the validation and storage stuff
    			$id = media_handle_sideload( $file_array, $post_id, $desc );
    			// If error storing permanently, unlink
    			if ( is_wp_error($id) ) {
    					@unlink($file_array['tmp_name']);
    					return $id;
    			}
    
    			$src = wp_get_attachment_url( $id );
    
    			if ($featured == true) {
    				echo 'setter framhevet bilde:'.$id.' på varenr:'.$featured;
    				set_post_thumbnail( $featured, $id );
    			}
    	}
    
    	// Finally check to make sure the file has been saved, then return the html
    	if ( ! empty($src) ) {
    			$alt = isset($desc) ? esc_attr($desc) : '';
    			$html = "<img src='$src' alt='$alt' />";
    			return $html;
    	}
    }

    Then I put three images named with product_id_0.jpg, product_id_1.jpg and product_id_2. The first for main product photo as featured image, and the two next as product gallery photos.

    In my marketpress-importer.php i added the new function, and added the inserts in the import loop like this:

    //insert first image (with ending '_0' for main image - is also to be set for featured image)
    $image_name = $row['artnummer'].'_0.jpg';
    $bilde_import = $this->eswd_media_sideloader($this->directories['import'].'/'.$image_name, 0,'', $new_id);

    and for the gallery photos:

    //insert second image go post gallery
    $image_name = $row['artnummer'].'_1.jpg';
    $bilde_import = $this->eswd_media_sideloader($this->directories['import'].'/'.$image_name, $new_id);
    
    //insert third image go post gallery
    $image_name = $row['artnummer'].'_2.jpg';
    $bilde_import = $this->eswd_media_sideloader($this->directories['import'].'/'.$image_name, $new_id);

    If you study the function usage, you will find that for the first one I set the 'post_id' to '0' to avoid to add this image to the products gallery, then I set the last parameter to the new_id to be able to set featured image with the 'set_post_thumbnail' function. For the two next I set filepath and post_id.

    ****

    The reason to do it this way is that the original function do not return the ID for the new image, and we need this to add it to the products postmeta '_thumbnail_id' using the 'set_post_thumbnail' function or the 'update_post_meta' function.

    There might be a better way to do this, but this is the best I can do for now :slight_smile:

  • espsjurs
    • The Incredible Code Injector

    I have now made a full working import where items are imported with variants, featured image, post gallery (two images) tags and custom fields (CustomPress).

    I have no idea if it would timeout importing a big csv with large images, but it work for my use.

    I will make public beta if requested :slight_smile:

  • aecnu
    • WP Unicorn

    Greetings Espen,

    Thank you again for sharing this news with the community, it is appreciated though of course it would be nice to have a shot at checking this out.

    The problem of timing out with large csv files will also vary from host to host depending on the setting in the php.ini file max_execution_time and if the host will indeed allow it to run for longer then what they want.

    Please advise.

    Cheers, Joe

  • espsjurs
    • The Incredible Code Injector

    Hi again aecnu,

    I have now an early version of this ready, and have added it to my download section on my site here.

    Features:
    – variants (tuned for shoes in the sizes 36-41
    – featured image
    – product gallery (two images)
    – missing image dummy
    – stock invatory on variant
    – sales-price
    – price

    Howto:
    – copy you images to wp-content/uploads/product/import
    – copy dummy.jpg to wp-content/uploads/product/import
    – all images must be named ITEMNUMBER_0.jpg, ITEMNUMBER_1.jpg and ITEMNUMBER_2.jpg where _0 is the main photo for featured image. _1 and _2 will be imported to the items gallery
    – struct your CSV as shown in sample-ext-marketpress-import.csv
    – start the import via the Importers tab from MarketPress, store settings

    It should be used in test only, and all comments is valued :slight_smile:

    yf
    Espen

  • aecnu
    • WP Unicorn

    Greetings Espen,

    Thank you so very much for this contribution to the WPMU Dev Community Members, it is certainly appreciated and some rep points sent your way.

    I personally encourage anyone who finds @Espen plugin useful to donate some rep points to him as well :smiley:

    The cream of the crop for me on this plugin would be if there was a way to just enter the URL for the graphics bypassing the featured image import if at all possible. But I am still grateful for any and all progress for this magnificent plugin developed by @Aaron

    Cheers, Joe

  • espsjurs
    • The Incredible Code Injector

    Hello again,

    I am now working on a new version of this importer with new features:

    Setup section with a few new options:
    - y/n to import image 1-3
    - y/n to custom field 1-3
    - name of custom field 1-3
    - y/n to import variant (yes I know - this should be controlled by the input in the CSV-file)

    If anyone has some ideas in these areas, please advise:
    - how can I use the same csv file layout to all kind of items?
    - how can variants be listed in the csv file for easy setup?
    -other..

    I know that if the variant was listed in separate lines it would be easier, but if someone want to use the excel file for more than just the import, this can be a bit tricky.

    So if someone already have a full spec on how a import with all kind of features would look like, please post it.

    First of all I work with this import function for my client, but if some small changes can make it work for others then I will try to do that :slight_smile:

    Espen

  • Tom Eagles
    • Syntax Hero

    Greetings and thanks for being a great community member.
    We haven't heard from you on this one for long and I am doing a regular followup to see if there is still something we can assist you on this thread.
    Just to manage the support issues more efficiently, I am marking this thread as resolved for now however this is not being done to avoid your questions in any way.
    Please feel free to mark this is "Not resolved" in case you have further questions and we would be back on it.
    Thanks a lot for being with WPMU DEV.
    Cheers!
    Tom
    Sales &Support
    Did you know we offer FREE lifetime memberships? Click here to learn more.

  • espsjurs
    • The Incredible Code Injector

    Hi aecnu,

    The code was for download in my other topic Custom Extended MarketPress product import from CSV for a while.. but it is still only a beta, and there was almost 30 downloads but no feedback - so I closed it. A beta without testing and feedback is not for anyone to install..

    If you give me a way to send you the code without putting it out to the public, I will do so - IF you promise to give me some feedback :slight_smile:

    yf Espen

  • aecnu
    • WP Unicorn

    Greetings Espen,

    Thank you for letting us know and your fantastic reply.

    Indeed I will give you some feedback but I must admit I am at this moment not doing a project to implement this and give that feedback as you deserve.

    Therefore I will be back at ya on this and if you want to communicate with me more directly my email is aecnu (at) incsub.com

    Thank you for your consideration.

    Cheers, Joe

  • espsjurs
    • The Incredible Code Injector

    Hi again aecnu,

    I have now mailed you the plugin, and I hope you find time to test it.

    Arun Basil Lal said not long time ago

    This is getting better and better. I had an email covo with Aaron and he said we would want to have this into the MarketPress core. This is too cool :slight_smile:

    I guess Aaron will rewrite my code, but hope that some credit will be given me :slight_smile:

    Espen

  • aecnu
    • WP Unicorn

    Greetings Espen,

    Thank you and yes I have received that coding and intend to test it soon in an upcoming project.

    Aaron is a man of integrity and if he uses your idea or a derivative of your coding I am sure he will give you some credit.

    Thank you for sending that over.

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.