How do I import flipkart products from a csv into

2019-06-10 02:37发布

问题:

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?

回答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 )



回答2:

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.