-1

I have a csv from flipkart with fields such as:

productId title description mrp price productUrl categories

Obviously these don't match up perfectly with the WooCommerce fields ( short description / long description vs description ), productId vs sku but does anyone have tips on how to go about matching these up to be compatible with WooCommerce, or can recommend any WP plugins that may do this?

meder omuraliev
  • 183,342
  • 71
  • 393
  • 434

2 Answers2

1

Woocommerce product is also a custom post type (product) only. you can easily write your own custom importer.

Each product may have the following structure

product - parent post
   -- attachment - featured image, gallery
   -- product meta - options, category, tags, price, stock ...
   -- variation - product variants (it also contains options, price, stock...) 

the importer flow will be like

createProduct() {}
uploadImages() {}
createProductMeta() {}
createProductVariants() {}

Woocommerce already has all the necessory codes you want, refer WP_PLUGIN/woocommerce/includes/api/class-wc-api-products.php

create_product( $data ) - line number 174
save_product_images( $id, $images ) - line number 1551
save_product_meta( $id, $data ) - line number 638
save_variations( $id, $data ) - line number 1080

trust me it's easy, i have already done that ( not for flipkart but shopify to woocommerce )

Sark
  • 4,458
  • 5
  • 26
  • 25
  • Do you have any advice as to actually starting the import code? I have experience with modifying but not creating plugins. Any links to some articles on that, or just where I'd create the files? – meder omuraliev Dec 29 '14 at 18:56
  • @meder sent me a sample csv for one product, so that i can modify my existing code ( shopify to woocommerce ) to your needs. – Sark Dec 29 '14 at 20:27
  • here you go: http://static.arounds.org/example.csv – meder omuraliev Dec 29 '14 at 22:22
  • 1
    find the sample implementation here http://sarkware.com/fliport.zip – Sark Dec 29 '14 at 23:41
  • Cool - thank you so much. Is there any reason you didn't just create say, a cron job to pull from a REST API vs manual csv importing? just no capability for shopify? I'm wondering if I should do the API way for FlipKart – meder omuraliev Dec 30 '14 at 19:05
  • Also created a new question for pairing products together, not sure if you have any idea but.. http://stackoverflow.com/questions/27711058/how-can-i-group-the-same-products-from-different-merchants-feeds-like-flipkart – meder omuraliev Dec 30 '14 at 19:06
  • @meder yes you are right, Shopify has REST API, we can pull all products from Shopify ( as json ) and Iterate through Json and prepare Woocommerce product object ( post ) and Insert it ( that's how i did it ). – Sark Dec 30 '14 at 20:09
  • @meder I never used cron job, just a normal Apache process enough for that. to import around 1500 products ( each has avg of 60 to 80 variants ) it took 9 hours. – Sark Dec 30 '14 at 20:13
  • If flipkart has REST API, go for it, JSON is 100% better that CSV. – Sark Dec 30 '14 at 20:15
0

For all imports you can use Wordpress wp_insert_post() function. You should create basic template for this work. Read data files with lines. And foreach it. While foreaching, define title, content or other fields.

Fatih SARI
  • 435
  • 4
  • 21