Feeds and Drupal Commerce 2 / Drupal 9

Feeds is such a great module. You can mass update all elements of your nodes, products, taxonomies, users, etc. It works by importing a source data file, where you carefully input all the fields you want to import for example with a CSV file. 

After you have mapped all the fields you can use the Feeds module to import that data straight into your nodes, products.....And if you are using Drupal commerce 2, you need to install the Feeds and  Feeds commerce module.

Feeds commerce is in the alpha stage currently, but it works fine. We were migrating our commerce 1 drupal store which was built with Drupal 7 to Commerce 2 which is a Drupal 9 based installation. After you require both modules with composer it is ready to migrate. 

Feeds Drupal 9 is very similar to Feeds Drupal 7 module. I will post some screenshots to make your life easier. I was stuck for several hours because I overlooked one element by mistake. I needed to bulk update some products we have in our commerce store. 

We have basically several thousands of items so manually updating the store is a waste of time. It would take me days of work. WIth feeds you can just map the fields and you are done in less than 10 minutes. In commerce 2 (Drupal 8, 9, 10) each product consists of product content type and product variation. 

Product variation is attached to product content type. You can change many elements here and structure your site how you want to, but product variation usually has prices, SKU, dimensions, weight etc. I needed to update the Dimension and Weight field for all products, so our UPS module will be able to calculate the shipping rate.

After you enable both modules via composer or manually in the admin you go to /admin/structure/feeds.

Then you click on ADD FEED TYPE          /admin/structure/feeds

Feeds Drupal Commerce

You select Fetcher, which was a CSV file in my case. I was uploading all the data from my computer. The import period was set to Off when you upload from the computer. 

Under parser settings, you select the default delimiter either TAB, Comma, or Semicolon. This depends on how you set up your CSV. I used ;  because sometimes you use commas inside that body text and that can mess up the mapping

feeds commerce drupal parser

Under processor settings you select the following:

feeds commerce drupal processor settings

Here you should decide if you are creating new variations? Or updating existent. I was updating existing product variations so these were my settings. You can also set to update existing variations, replace, or not update.

Then there is mapping, the most important step in feeds migration. 

feeds commerce drupal mapping

Here you can select which fields you will update, replace, etc in your product variations. I needed to update the Weight and Dimensions for my products.

You have to use a field that will serve as a unique identifier for your CSV file. It means that each product variation has a unique SKU. Based on that you can successfully import data. Feeds will now know where to input data and for which variation because you just included SKU as a reference field. 

For each mapped field you select   SELECT TARGET which will give you a dropdown of all available fields that are in your product variation content. When you select a field for example SKU, then a new box will appear on the left SELECT SOURCE (THIS STEP I MISSED FOR ONE FIELD), and it delayed the whole thing for hours). You select then NEW CSV and input the name of the field in the box, in my case SKU. Also, mark it unique.

feeds commerce select source

Press Save and you are almost done. 

The next step is to go to  /admin/content/feed and create a new Feed.

With this step, you tell feeds where is your CSV file. After you press ADD you will see the list of previously made FEEDS and just select the right one. In my case it was product variation feed.

feeds commerce feed file

Insert a title, browse for the CSV file and select Delimiter, this is important. Select the same delimiter you will use in CSV file to divide items. Press Save and you will have the option to Import. Press import and this should be it. 

And here is the screenshot of my CSV file if you open it with notepad where you can see that the first line are fields I wanted to update, the second line values. I used semicolons to separate data.

feeds commerce CSV sample

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.