Skip to main content
Updates / The Best Way to Import OpenCart Products into WooCommerce
← All updates
 
Blog

The Best Way to Import OpenCart Products into WooCommerce

OpenCart keeps every product its users sell in its database, which makes the database the easiest place to start when you import OpenCart products into WooCommerce. A single query can copy the whole catalog into one CSV, with full image URLs and with categories written the way WooCommerce reads them.

WP All Import then imports simple and variable OpenCart products into WooCommerce in the same run, giving each size or color its own price and stock. Most of the preparation happens in the query, so that’s where I’ll start.

Which OpenCart Tables Fill a WooCommerce Product Page

A WooCommerce product page looks like a single record, but OpenCart stores the same product across several database tables. The name and description sit in one table and the price and stock in another, while extras such as gallery images and size options each have a table of their own.

The page below is an Insulated Water Bottle from the example store I used for this guide, sold in three sizes. Each label names the OpenCart table that part of the page comes from, along with the product-form tab where you’d edit it.

Where each part of the page comes from
  • 1Breadcrumb and categories
    oc_product_to_category and oc_category_path · Links tab
  • 2Title and description
    oc_product_description · General tab
  • 3Price, SKU and stock
    oc_product · Data tab
  • 4Sale price
    oc_product_special · Special tab (3.x, 4.0)
    oc_product_discount · Discount tab (4.1)
  • 5Size dropdown
    oc_product_option_value · Option tab
  • 6Main image and gallery
    oc_product and oc_product_image · Image tab
  • 7Product URL
    oc_seo_url · SEO tab

OpenCart’s admin does not have a product export that pulls these tables together. Its System › Maintenance › Backup / Restore tool saves them as an .sql file, but each table stays separate in that file, so a product’s name and its images still end up in different places. The query in the next section joins them back into one row per product.

Copy the Products Out of OpenCart with One Query

The OpenCart query runs in phpMyAdmin, which most hosting control panels include. Open it, select your OpenCart database in the left-hand list, and go to the SQL tab. This method does need that database access. 

If your host doesn’t give it to you, the free Export/Import Tool extension can export your products instead, but its Excel workbook spreads them across several sheets that you’d have to first combine before importing.

Choose the tab for your OpenCart version below. The version number is shown at the bottom of every OpenCart admin page.

Export query · pick your OpenCart version
-- Export OpenCart products as one WooCommerce-ready CSV (OpenCart 3.x)
-- Change the two settings on the FROM line: your image folder URL and your language ID.
-- Sale prices come from the Default customer group (ID 1).
SELECT
  r.`SKU`,
  r.`Parent SKU`,
  REPLACE(REPLACE(REPLACE(REPLACE(r.`Name`, '&lt;', '<'), '&gt;', '>'), '&quot;', '"'), '&amp;', '&') AS `Name`,
  REPLACE(REPLACE(REPLACE(REPLACE(r.`Description`, '&lt;', '<'), '&gt;', '>'), '&quot;', '"'), '&amp;', '&') AS `Description`,
  r.`Regular price`,
  r.`Sale price`,
  r.`Stock`,
  r.`Weight`,
  REPLACE(REPLACE(REPLACE(REPLACE(r.`Categories`, '&lt;', '<'), '&gt;', '>'), '&quot;', '"'), '&amp;', '&') AS `Categories`,
  IF(r.images = '', '', CONCAT(s.image_url, REPLACE(r.images, ', ', CONCAT(', ', s.image_url)))) AS `Images`,
  r.`Slug`,
  r.`Status`,
  r.`Attribute 1 name`,
  r.`Attribute 1 value(s)`
FROM (SELECT 'https://yourstore.com/image/' AS image_url, 1 AS language_id) AS s
JOIN (
  -- One row per product (simple products and the parents of products with options)
  SELECT
    p.product_id, 0 AS row_order, 0 AS value_order, 0 AS pov_id, pd.language_id,
    IF(p.sku <> '', p.sku, p.model) AS `SKU`,
    '' AS `Parent SKU`,
    pd.name AS `Name`,
    pd.description AS `Description`,
    ROUND(p.price, 2) AS `Regular price`,
    IFNULL((SELECT ROUND(ps.price, 2) FROM oc_product_special ps
            WHERE ps.product_id = p.product_id AND ps.customer_group_id = 1
              AND (ps.date_start = '0000-00-00' OR ps.date_start <= CURDATE())
              AND (ps.date_end = '0000-00-00' OR ps.date_end > CURDATE())
            ORDER BY ps.priority, ps.price LIMIT 1), '') AS `Sale price`,
    p.quantity AS `Stock`,
    ROUND(p.weight, 2) AS `Weight`,
    IFNULL((SELECT GROUP_CONCAT(c.path ORDER BY c.category_id SEPARATOR '|')
            FROM (SELECT p2c.product_id, p2c.category_id, cd.language_id,
                         GROUP_CONCAT(cd.name ORDER BY cp.level SEPARATOR ' > ') AS path
                  FROM oc_product_to_category p2c
                  JOIN oc_category_path cp ON cp.category_id = p2c.category_id
                  JOIN oc_category_description cd ON cd.category_id = cp.path_id
                  GROUP BY p2c.product_id, p2c.category_id, cd.language_id) AS c
            WHERE c.product_id = p.product_id AND c.language_id = pd.language_id), '') AS `Categories`,
    CONCAT_WS(', ', NULLIF(p.image, ''),
              (SELECT GROUP_CONCAT(pi.image ORDER BY pi.sort_order SEPARATOR ', ')
               FROM oc_product_image pi WHERE pi.product_id = p.product_id)) AS images,
    IFNULL((SELECT su.keyword FROM oc_seo_url su
            WHERE su.query = CONCAT('product_id=', p.product_id)
              AND su.store_id = 0 AND su.language_id = pd.language_id LIMIT 1), '') AS `Slug`,
    IF(p.status = 1, 'publish', 'draft') AS `Status`,
    IFNULL(od.name, '') AS `Attribute 1 name`,
    IFNULL((SELECT GROUP_CONCAT(ovd.name ORDER BY ov.sort_order, pov.product_option_value_id SEPARATOR '|')
            FROM oc_product_option_value pov
            JOIN oc_option_value ov ON ov.option_value_id = pov.option_value_id
            JOIN oc_option_value_description ovd ON ovd.option_value_id = pov.option_value_id
                 AND ovd.language_id = pd.language_id
            WHERE pov.product_option_id = po.product_option_id), '') AS `Attribute 1 value(s)`
  FROM oc_product p
  JOIN oc_product_description pd ON pd.product_id = p.product_id
  LEFT JOIN oc_product_option po ON po.product_option_id = (
       SELECT MIN(po2.product_option_id) FROM oc_product_option po2
       JOIN oc_option o2 ON o2.option_id = po2.option_id
       WHERE po2.product_id = p.product_id AND o2.type IN ('select', 'radio'))
  LEFT JOIN oc_option_description od ON od.option_id = po.option_id AND od.language_id = pd.language_id

  UNION ALL

  -- One row per option value, placed under its parent, with the full price worked out
  SELECT
    p.product_id, 1, ov.sort_order, pov.product_option_value_id, pd.language_id,
    CONCAT(IF(p.sku <> '', p.sku, p.model), '-', UPPER(REPLACE(ovd.name, ' ', ''))),
    IF(p.sku <> '', p.sku, p.model),
    pd.name,
    '',
    ROUND(p.price + IF(pov.price_prefix = '-', -pov.price, pov.price), 2),
    IFNULL((SELECT ROUND(ps.price + IF(pov.price_prefix = '-', -pov.price, pov.price), 2)
            FROM oc_product_special ps
            WHERE ps.product_id = p.product_id AND ps.customer_group_id = 1
              AND (ps.date_start = '0000-00-00' OR ps.date_start <= CURDATE())
              AND (ps.date_end = '0000-00-00' OR ps.date_end > CURDATE())
            ORDER BY ps.priority, ps.price LIMIT 1), ''),
    pov.quantity,
    ROUND(p.weight + IF(pov.weight_prefix = '-', -pov.weight, pov.weight), 2),
    '',
    '',
    '',
    IF(p.status = 1, 'publish', 'draft'),
    od.name,
    ovd.name
  FROM oc_product_option_value pov
  JOIN oc_product_option po ON po.product_option_id = pov.product_option_id
  JOIN oc_product p ON p.product_id = pov.product_id
  JOIN oc_product_description pd ON pd.product_id = p.product_id
  JOIN oc_option_description od ON od.option_id = po.option_id AND od.language_id = pd.language_id
  JOIN oc_option_value ov ON ov.option_value_id = pov.option_value_id
  JOIN oc_option_value_description ovd ON ovd.option_value_id = pov.option_value_id
       AND ovd.language_id = pd.language_id
  WHERE po.product_option_id = (
       SELECT MIN(po2.product_option_id) FROM oc_product_option po2
       JOIN oc_option o2 ON o2.option_id = po2.option_id
       WHERE po2.product_id = p.product_id AND o2.type IN ('select', 'radio'))
) AS r ON r.language_id = s.language_id
ORDER BY r.product_id, r.row_order, r.value_order, r.pov_id;
The highlighted FROM line holds the two values to change: your image folder URL and your language ID.

Before you click Go, change the two values on the query’s FROM line:

  • Image folder URL: replace https://yourstore.com/image/ with your store’s address followed by /image/. WP All Import downloads every product image from that folder, so keep the OpenCart store online until the import is finished.
  • Language ID: a store with one language can leave this as 1. Otherwise, go to System › Localisation › Languages, edit the language you want, and use the number after language_id= in the page address.

If your table names in phpMyAdmin start with something other than oc_, replace every oc_ in the query with your own prefix.

The query also deals with two quirks in OpenCart’s data. OpenCart requires a Model for every product but not a SKU, so the query uses the Model wherever the SKU is blank. OpenCart also saves product text with its HTML tags encoded, storing a paragraph as &lt;p&gt; instead of <p>. The query decodes this, so descriptions keep their formatting in WooCommerce.

Click Export under the results and choose CSV. Then switch to Custom and check that Put columns names in the first row is ticked. The file that downloads is the one you’ll import.

Add Option Rows for Products Sold in Sizes or Colors

OpenCart and WooCommerce price product options differently. An OpenCart option value holds a price adjustment, such as +4.00, and a stock count of its own, while a WooCommerce variation needs its full price.

The second half of the query handles this. It writes one row for each value of a product’s Select or Radio option and places those rows directly under the product’s own row. Each one gets the full price, worked out from the product’s price plus the adjustment, and a Parent SKU that points back to the product. OpenCart option values don’t have SKUs, so the query builds one for each variation from the product’s SKU and the option value.

In the example store, the Insulated Water Bottle costs 24.00, and its Size option adds 4.00 for 750 ml and 7.00 for 1 litre.

One OpenCart option, three WooCommerce variations
OpenCart Size option
  • 500 ml+0.00
  • 750 ml+4.00
  • 1 litre+7.00
Product price: 24.00
WooCommerce Variations of Insulated Water Bottle
  • TRL-BTL-01-500MLSize: 500 ml24.0024.00 + 0.00
  • TRL-BTL-01-750MLSize: 750 ml28.0024.00 + 4.00
  • TRL-BTL-01-1LITRESize: 1 litre31.0024.00 + 7.00

WP All Import links each variation row to its parent product through the Parent SKU column, so an OpenCart Size option shows up in WooCommerce as a working size dropdown.

The query uses only the first Select or Radio option on each product. OpenCart tracks stock for each option value on its own, rather than for combinations such as a medium in blue. That means a product with both a Size and a Color option comes across with its first option only, and you’d add the second one in WooCommerce afterward.

Import the OpenCart CSV with Automatic Setup 

The import runs in WP All Import Pro with the WooCommerce Import Add-On. Automatic Setup handles the mapping, and three settings in Manual Setup finish the job before the import runs.

Step 1: Upload the OpenCart CSV to Automatic Setup

Go to All Import › New Import and click Set up automatically. On the Upload File tab, drop in the CSV you exported from phpMyAdmin.

wp-all-import-automatic-setup-upload-opencart-csv

Step 2: Choose WooCommerce Products and Leave the Notes Empty

Select Products under WooCommerce Import, leave the optional Add Setup Instructions box closed, and click Start Automatic Setup. The query gave its columns the same names as WooCommerce’s own fields, so this file doesn’t need any notes. WP All Import’s Automatic Setup matches columns named after WooCommerce fields, such as Regular price and Parent SKU, to those fields without setup instructions.

wp-all-import-choose-what-to-import-opencart-products

Step 3: Check the Field Mappings and the Unique Identifier

The Your Import Is Ready screen shows how many fields were mapped and how many records were found. Every row below the CSV’s header counts as a record, variation rows included. My example file has six products and six variation rows, so the screen shows 12 records.

wp-all-import-your-import-is-ready-opencart

Under Field Mappings, Product Type reads variable, and Parent Product ID uses the Parent SKU column. WP All Import still imports products without variation rows as simple products, so the sunglasses and the pencil case come through ready to add to the cart. Click Manual Setup to check three more settings before the import runs.

Attributes. In the WooCommerce Add-On’s Attributes tab, keep a single attribute row with {attribute1name[1]} as its Name, and delete any other row. That row reads each product’s own option name from the file, so the bottle’s attribute becomes Size and the backpack’s becomes Colour.

wp-all-import-attributes-opencart-option-name

Categories. If any product sits in more than one OpenCart category, open Taxonomies, Categories, Tags › Product categories, tick Separate hierarchy groups via symbol, and enter |. Each category path then becomes its own WooCommerce category. For my pencil case, that’s Pencil Cases under Stationery, plus Gifts on its own.

wp-all-import-categories-hierarchy-groups-opencart

Unique Identifier. Click Continue to reach Import Settings, and set Unique Identifier to {sku[1]}. Re-running a WP All Import import with {sku[1]} as its Unique Identifier updates the existing WooCommerce products instead of creating new ones, even after a product gains a new size.

wp-all-import-import-settings-unique-identifier-opencart-sku

Step 4: Run the Import and Open a Product Page

Click Continue, then Confirm & Run Import. The finished screen lists how many records were created, which was all 12 for the example file.

wp-all-import-opencart-import-complete

Open a product with options in your store to try its dropdown. Picking a size on the bottle brings up that variation’s own price and stock count.

woocommerce-opencart-variable-product-dropdown.gif

Product images come across in the same run. WP All Import downloads each image from the URLs in the CSV and uses the first one as the featured image, with the rest going into the product gallery, as on the sunglasses.

woocommerce-opencart-product-gallery

Final Thoughts

The best way to import OpenCart products into WooCommerce starts with exporting them straight from OpenCart’s database with one query. The database already knows which rows in which tables belong to each product, so joining them there produces a single CSV with a row for every product and every variation. WP All Import carries each product’s OpenCart SEO keyword over as its WooCommerce URL slug, so product addresses keep the same wording after the move.

Products are often only the first part of moving an OpenCart store. WP All Import imports WooCommerce orders, customers, coupons and reviews through the same Automatic Setup steps used for this catalog, so once those records are exported from OpenCart, they can follow the products into your new store.

Common Questions About Importing OpenCart Products into WooCommerce

How do I migrate products from OpenCart to WooCommerce?

You can migrate products from OpenCart to WooCommerce with WP All Import by exporting them from OpenCart’s database and importing the CSV:

  • Run the export query for your OpenCart version in phpMyAdmin’s SQL tab.
  • Click Export under the results and save them as a CSV, with Put columns names in the first row ticked.
  • In WordPress, go to All Import › New Import and click Set up automatically.
  • Upload the CSV, choose Products, and click Start Automatic Setup.
  • In Manual Setup, check the attribute and category settings, then set the Unique Identifier to {sku[1]}.
  • Click Confirm & Run Import, then open a product page in your store to check the result.

Is there a way to export OpenCart products without phpMyAdmin?

Yes. You can export OpenCart products without phpMyAdmin by installing an export extension such as the free Export/Import Tool, which saves your products to an Excel workbook. The workbook spreads product data across several sheets, so combine the product details into one sheet before importing. WP All Import imports Excel files directly, so the sheet doesn’t need to be converted to CSV first.

Does WooCommerce have product options like OpenCart?

Yes. WooCommerce handles product options like OpenCart’s through attributes and variations, and each variation of a variable product carries its own price and stock. OpenCart’s Select and Radio options are the closest match, which is why the export query turns them into variation rows. For more on how attributes behave during an import, see How To Import Attributes for WooCommerce Variable Products.

Do I need to create my categories in WooCommerce before importing OpenCart products?

No. WP All Import creates WooCommerce product categories during the import, building each Parent > Child path from the CSV’s Categories column. In the example store, the import created a Drinkware category with Bottles nested under it, without any prior setup in WooCommerce.

Further Reading

Get Oxygen

Build it your way with Oxygen.

$199.50 once — unlimited sites, no renewal

Not per year, not per site, not per seat. 60 day money back guarantee.