When trying to import products, it failed giving the following error for each attempted import:

Illegal offset type in isset or empty File /home/quickstart/websites/sooper74.dev/sites/www.sooperthemes.com/modules/commerce/commerce.module, line 414

This error resulted from passing an array into the price field for product entities instead of a string.
This happens in product.inc line #73:

    $arguments = MigrateCommercePriceFieldHandler::arguments(array('USD'));

Even if this worked it would be bad for every shop that uses a currency other than USD.

I think this is easily fixed by simply removing the argument here, because in the price field handler it does this:

      $currency_code = isset($arguments['currency_code']) ? $arguments['currency_code'] : commerce_default_currency();

So when the argument is omitted it loads the default currency that is configured for the Commerce installation.

Comments

vaccinemedia’s picture

I get the same error. I'm trying to upgrade my Ubercart 2 store to a commerce Drupal 7 installation. I've imported my users from the old store and now I;m trying to import products with this error message. What's the solution?

dwkitchen’s picture

fortina: I deleted line 73 and then changed every reference to USD to (in my case) GBP

dwkitchen’s picture

Here is a patch that removes the enabling of USD and will save the incoming values as your stores default currency instead of USD.

I might be possible to go further and and do this based on the currency used in Ubercart.

pianomansam’s picture

Status: Active » Needs review

I also ran into this issue, and the patch from #3 fixed my problem.

mandreato’s picture

Status: Needs review » Reviewed & tested by the community

#3 worked for me too

torgospizza’s picture

So glad I found this issue, as I ran into it as well. The patch in #3 solved it and allowed me to import my products.

The patch makes sense because the value that commerce_currency_load() seems to always be a string, and not an array; using an array as a key to another array results in Illegal offset error as described in http://php.net/manual/en/language.types.array.php

Please consider committing this!

mariagwyn’s picture

+1 to patch, made my import work.

rfay’s picture

rfay’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.