Importing Products using Feeds

The wonderful Commerce Feeds module, with its parent Feeds allow you to import various kinds of feeds as products and/or as product reference nodes. Edit: You may be also be interested in Commerce Migrate and this screencast on how to use it to import Ubercart stores.]

Importing Products with Commerce Feeds from Randy Fay on Vimeo.

In this example we'll be bringing in a CSV feed and turning it into both products and product reference nodes in two separate operations.

Our CSV has just a few fields and the first couple of lines look like this:
"SKU","Title","Price","Image","Description"
"0023548568","Computer Graphics Using Open GL (2nd Edition)","11000","http://ecx.images-amazon.com/images/I/51JQbhO0MmL.jpg","Great book blah blah..."

The SKU is the unique identifier for the product, and of course the other items are self-descriptive. The Image is a URL to an image.

You can view and explore the feed at http://d7.randyfay.com/books/feed. Note that this is just an example feed - it could be something other than CSV, the fields could be named differently, etc. We do need a unique identifier (the SKU), which we'll also use to map the product reference nodes to products.

An Outline

  • Install and enable feeds and commerce_feeds
  • Create a new feed importer named "Product Importer" at Administration -> Structure -> Feeds
    • Change the parser to "CSV Parser"
    • Change processor to "Commerce Product Processor"
    • In "Commerce Product Processor" settings use product type "product" (or whatever your product is) and change the "Author" to your username.
    • In "mapping", map
    • SKU -> Product SKU
    • Title -> Product Title
    • Price -> Price: Amount
    • Image -> Image
    • Set ID as unique target.
  • Visit /import, use the Product Importer.
  • Visit the products page (admin/commerce/products) to view your new products
  • Note that you can delete items using the feed or with commerce_vbo
  • Now we'll import the same data again, but this time we'll turn it into product display nodes.
  • Go to admin/structure/feeds and create a new feeds importer
  • Change the parser to CSV
  • Change the processor to Node Processor
  • Choose the "Product Display" node type
  • Set the author to yourself
  • Under mappings
    • SKU -> GUID (and set unique target)
    • Title -> Title
    • Description -> Body
    • SKU -> Product SKU
  • Visit /import
    • Use the Product Reference Importer
    • Use the same feed URL: http://d7.randyfay.com/books/feed
    • Now you have 100 shiny new product reference nodes, pointing to products.
If you need to import products with additional attributes or other fields, that works fine too; you'll need the "Feeds Tamper" module for it. Here's the screencast demonstrating it, followed by the recipe. Update 26 Sept 2011: The "Feeds Tamper" tab is now an Operation as "Tamper" in Feeds
  1. Add your attribute to the product type
  2. Add the attribute to your csv file
  3. Change the mappings in the product importer to add the attribute
  4. Import.
  5. Create a node import CSV file that has the list of products as comma-separated within the quotes: "SKU1,SKU2,SKU3"
  6. Create a node import feeds importer (or just use the standard one from commerce_feeds_example)
  7. Create a feeds tamper rule at admin/structure/feeds tamper that explodes the SKU field in the node as it imports.
  8. Import your nodes.
If you need to import prices that are not in minor units (they're $1.50 instead of 150) then this screencast explains how to use Feeds Tamper to transform them on import:

Drupal Commerce: Using Feeds Tamper to change Dollars/Cents to Minor Units from Randy Fay on Vimeo.

NOTE: the above tutorial references an example product feed that is no longer available. We suggest you create your own example file with the required fields to complete the import

Found errors? Think you can improve this documentation? edit this page