Found a way to import to MarketPress via XML Feed

Wanted to share how I was able to import products, images and prices into Marketpress via live XML feed - can also use RSS and CSV files. Points appreciated if it helps to solve your troubles :slight_smile:

  • synergy3c

    Hi all. I am setting up a CMS that can import a variety of data from other sites in order to use that data in mobile phone apps. Some of these sites will be other ecommerce sites and it was preferable that I use a feed import rather than a one-off CSV import.

    As MarketPress is the only commerce plugin I'll use for the network, I had to find a way to do this. I found a plugin called WP All Import ( It costs 99-299 depending on license choice. Might seem expensive but since it can import anything (CSV, XML, RSS by url or upload) to anything it's worth the time saved seeking other solutions. Plus it and can be set to reimport at regular intervals. So it keeps the MarketPress products up to date.

    The only difficult thing I had to do was figure out the names of the fields associated with MarketPress and map the XML nodes to them (not that hard, really, though).

    I also used CustomPress to create a custom field for 'Brand' and mapped the XML feed node to it. In my example, I chose to use the GoogleShopping.xml feed that was created by the Magento site I was importing from. I also tested other feed types (Get Price and others) and it worked fine. I chose to use the Google feed as it contains more values (eg, weight and inventory).

    After I installed the plugin, I just had to create my first import. I followed the steps and entered the url to the xml feed/file I was importing. Next, I selected the repeating parent node I wanted to import (in this example, I chose the ‘item’ node as given by the GoogleShopping.xml structure). This was just a matter of a click.

    On the next step I mapped the nodes to the correct fields. When doing this, the plugin shows a standard ‘New Post’ entry form page. I mapped the name of the product to the title of the post, and the ‘description node’ to the body of the post.

    After some trial and error I figured out that I had to select the ‘post’ type (not product) for the ‘Custom Fields For Post Type’ setting. When this was selected, I was able to add several and unlimited additional field mappings (see screen shot).

    Finally, in the following screen I assigned the correct category node to the category section (to assign and create categories for the product catalog). Then, I assigned the image url to the 'Featured image' field. Finally, I used the product node id as the field to check if the product exists on new imports. If it does, the new import will update that product details or leave it alone (as you choose).

    Now.. the only troubles I ran into was not being able to add the product weight. I used 'mp_shipping_weight' as the field name, but no luck. Also, tried to map to 'excerpt' for the excerpt field, but no luck. Any advice from devs?

    One more thing.. my imports and most my product feeds use GRAMS as a weight value. But MarketPress uses kilograms. This to me is problematic for obvious reasons. Regardless... it seems to make more sense to me that the global weight setting should be grams, not kilos - can this be changed somehow?

    Oh! Also, is there a way to add more images for the product?


  • synergy3c

    @Aaron. Thanks - I will try adding the first "0" key variation and get back to you.

    I also had some other questions buried in my post - can you help?:

    My imports and most my product feeds use GRAMS as a weight value. But MarketPress uses kilograms. This to me is problematic for obvious reasons. Regardless... it seems to make more sense to me that the global weight setting should be grams, not kilos - can this be changed somehow?

    Finally, is there a way to add more images for the product? I only see the featured images field...

  • synergy3c

    @Aaron. Ok, thanks. That's interesting.. every ecommerce site I've built uses grams. Suppose the challenge was in being able to import products. So if a feed I am connecting to has weights in grams, then it would have been good to be able to set the global weight settings to grams. Otherwise, the feed is giving 250 (in grams) but MarketPress is importing it as 250 KGs. I cannot see how i can convert a live feed from kilos to grams with math - do you have a suggestion? Thanks

  • synergy3c

    @Aaron Just more on the weight import, mate. I mapped to the field name mp_shipping (as per the csv import file). My weights get imported (as grams) and get rounded and added to both the Extra shipping cost field and the weight field. So for an item that weighs 225grams, it shows its weights as 2 (kilograms) and also adds a extra cost of $2.00. Indeed, For items that weigh 200 up to 299 grams, it shows as 2 (kilograms) and also adds a extra cost of $2.00. Items that weight 100 to 199 show as 1 (kilogram) and also adds a extra cost of $1.00 and Items that weight 300 to 399 show as 3 (kilograms) and also adds a extra cost of $3.00.

    Seems that rounding does some odd things and makes weights inaccurate.

    Also, in the conditional statement in the csv import file allocates the mp_shipping field data to both the wight and extra costs fields. I cannot 'target' them separately. I have tried 'mp_weight' and 'weight' with no luck

    Code sample from csv import file:

    //add shipping info
    			$shipping = array();
    			if (!empty($meta_data['shipping']['local']))
    				$shipping['extra_cost'] = round( (float)preg_replace('/[^0-9.]/', '', $meta_data['shipping']['local']), 2 );
    			if (!empty($meta_data['weight']))
    				$shipping['weight'] = round( (float)preg_replace('/[^0-9.]/', '', $meta_data['weight']), 2 );
    			update_post_meta($new_id, 'mp_shipping', $shipping);

    I wonder if it affects the CSV import too? How can this be addressed?


  • shawng

    This might be exactly what I have been looking for, I have a few posts on it already.

    I have multisite setup where each of my clients has their own store.

    All of their products are 'clones' of my 'primary store'. In other words, clients do not have inventory control. They can only sell whatever I offer them to sell.

    So if I add a product to my store, it is added to theirs, same goes if I remove a product.

    Using your script, would it be possible to auto update the 'child' multisite stores via xml from the parent store?

    i.e. I add a product to my main store, that product gets added to the xml, which auto fires to the child store xml import and their inventory changes...

    *My idea is that the 'child' multisite stores, are not really storefronts, but really more a super fancy affiliate program that looks like a store for my clients as they really don't have any control.

    If your plugin can do that, then I have no problem spending the $$$ for it.

  • shawng

    Wow, this is hands down one of the most amazing plugins I have come across in a long time. Thanks for the link and heads up on it.

    My primary cart system is woocommerce and always will be, but I like the idea of using marketpress for my 'affiliate sites'.

    Now all I have to do is to figure out how to make the 'buy now' link on the marketpress affiliate sites an affiliate link to buy the product on my primary woocommerce site.

    Have you tried anything like this with marketpress?

  • synergy3c

    HI Shawng.. the plugin I have mentioned is not mine, so I cannot give any development services on it, sorry. I am sure you could set up an automatic import of your product into their sites however. I expect that It is just a matter of setting up (manually for the first time) the import of your products to their site. You would just set the plugin to update the feed every day (or so) to keep their store up to date with your products.

    As far as your 'buy now' link question - if you map the url to the page where your product can be purchased in your woocommerce site to the 'mp_product_link' field (as per my screen shot) MarketPress will automatically change the 'add to cart' button/function to a link to the page where the customer can buy the product.


  • shawng

    Totally awesome. I got the plugin and absolutely love it! This is hands down one of the coolest little toys I have gotten in a long time.

    I'm hoping that maybe you can help me with one last thing. I created an export file with woocommerce

    That file has a lot of woocommerce products in it. (it's their dummy xml file import on a pretty much virgin wp install)

    What I can't figure out is how to properly map one of their 'items' to the marketpress store. Especially the area dealing with the images.

    By any chance would you have the time to take this xml file, grab an item, and show me how to map these fields to the custom fields used by marketpress?

    *That would basically create a master woocommerce -> marketpress sheet that anyone using the importer plugin could use as it is standard.

    thanks so much for your time.

  • synergy3c

    HI Shawng

    If you want the import plugin to work for best effect, you should be importing a live XML feed, not a downloaded file.

    Have you set up a feed thats serves, say, Google shopping or another type of feed that includes price, weight, description, name and image. The feed you have provided is a bit complex (with wp metadata) and would be complex to figure out to map. I'm no expert in XML so I would not know how to do this one. But you can, like I did, use a bit of trial and error to figure out how to target the specific nodes you need.

    Above in my screenshot is a depiction of the field names I've figured out and have mapped to, to enter the fields.

    As far as the image and categories, you map them on the final step of your import process


  • shawng

    Good question.... I have no idea if woocommerce provides a live XML feed. I need to find that out for sure. man I hope they do, that would make it much easier.

    That file I linked to for you is a standard WordPress export xml file. The only difference is that my demo site had woocommerce products in there. As you can see, WordPress doesn't really give you 'pretty' links to the image, but rather gives you the fields you need to build the links to the images.

    I'll figure it out and post it when I do. Just wasn't sure if you had already done so, mapping woocommerce fields -> marketpress.

  • shawng

    That's just it, it can import ANY xml/csv feed including WordPress should you want to.

    In fact, i am actually importing a WordPress feed for one of my projects and it worked perfectly.

    Woocommerce does not give me any way of determining the page link when exporting the products. So what I did was exported the WordPress xml feed itself, choosing to only export the 'product' post-type.

    I then use that xml feed and input it into the allimport plugin on another site and use that to create 'product' posts. It worked perfectly. That's the great part about this plugin in that it can work with any feed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.