How can I import and export Drupal Commerce Products?

I have a Drupal 7 site and installed the Drupal Commerce module. In which I have added Commerce Product with Category like:

  • Software Products
  • Hardware Products
  • Electronics
  • Others

I would like to Export those Commerce Products from My Development Server to Production Server.

So, for that we have any modules available in so, I can export the Commerce Products and Import to my server.

I found the Node_Export module, but it only applies to exporting the nodes. It does not apply to Commerce Products.

Anyone has an idea how I can Import/Export the Commerce Module Products? I think it is general problem who are using the Commerce Module of Product (but not sure).

Answers 6

  • Commerce Feeds multitype

    Commerce Feeds multitype provides an additional Feeds processor that can create different types of products in one import. It provides mapping targets for the product type and any fields attached to any product type. If you're updating an existing product, any product type data in the source will be ignored.

    enter image description here

  • There is a great explanation here about exporting from Views both the Products and the Product Displays and then importing using Feeds and associated modules.

    So to export those products, we first create a view containing the products and then export this view via Views data export into CSV file.

    1. Install views_data_export and dependent modules

       drush en views_data_export image_url_formatter
    2. Create a view with products you like to export.

    3. Configure View for export (Data export).

    4. Generate the file via drush command, e.g.

       drush views-data-export --format=csv VIEW-NAME VIEW-DISPLAY-NAME exports/product-exports/theme_export_Jan11_2014.csv --quote-values --strict=0 --header-row

    To import:

    1. Install commerce_feeds module and its dependent modules, e.g.

       drush en feeds feeds_ui commerce_feeds
    2. Create New Feed Importer.

    3. Run import.

      Go to /import URL, use the Product Importer and import your products.

    Similar goes for Product Displays.

    See also:

  • Another option that might work to export any data from any Drupal database table is to use the export capabilities of the Forena module (it comes with quite some community documentation).

    About Forena: it is built of the idea of using SQL to get data out of a database (which can be the Drupal database or an external one such as My SQL, Oracle, MS SQL, ...) and use XHTML and CSS to format it into web reports. Visit the Forena HowTos page for some links (near the bottom) to some live demo / showcase links.

    Exporting data

    Any report can be exported (saved) in various file formats, such as CSV, XLS, PDF, DOC, ... To do so, just add an extention to the report (output) URL that corresponds to the format you want (like .csv for CSV format). That contains the equivalent of that report (in the requested format). As a sample, consider the sample report located at /reports/sample.states (in your own site, one of the samples shipped with Forena). Change the URL to /reports/sample.states.csv (= just add .csv to it) to get the same report in .csv format. If you'd add such .csv to the URL of the Simple Table of States in the demo site, the result is like so ...

    Same technique applies for other supported extensions (export formats), such as adding .html, .xls (MS Excell), .pdf or .doc (MS Word).

    By the way, all data blocks are accessible directly via their url also, provided you have permission to access that block. Here are a few samples of that, for the sample report located at /reports/sample.states:

    For short, to answer this specific answer I'd write the various (custom) SQLs I need, format it as reports that fit my needs, and then just save it as a CSV (Or XML? Or JSON?).

    Importing data

    Using the Forena integration with the Feeds module it is possible to import data blocks.

    For a tutorial about the available features check out the video about How to import data and reports based on data as Drupal nodes.

    Disclosure: I'm a co-maintainer of the module.

  • The best way to export/import products is features. You will need to use uuid, uuid_features and commerce_uuid modules to archive this.

Related Questions