smack-a-bro
smack-a-bro

Reputation: 741

How do I fix this fatal error in OpenCart?

I am using CSV Import Pro to import products into my store using OpenCart.

The other day I was importing products which was going fine. Then after an import the extension keeps giving me this fatal error.

I've tried contacting support for damn near 5 days and I haven't gotten much from them. I really need to get this fixed.

Fatal error: Cannot use object of type stdClass as array in /home/content/71/11151671/html/admin/view/template/tool/csv_import.tpl on line 234

Usually there are tabs at the top that let me navigate to the other pieces of the module.

It would not let me post images

Upvotes: 1

Views: 768

Answers (3)

Peter Stuart
Peter Stuart

Reputation: 2434

With the CSV Import Pro you want to go to the admin/controller/tool/csv_import.php

Search for this line of code:

$this->data[$key] = json_decode($this->data[$key];

and replace it with:

$this->data[$key] = json_decode($this->data[$key], true);

By adding the true at the end, you are basically telling the script you want your data to be in an array format, rather than an object.

Hope this helps ;)

Peter

Upvotes: 1

RomanGor
RomanGor

Reputation: 4475

If you split a JSON-object, try to add a second parameter to the function json_decode:

$json = json_decode($string, true);

Upvotes: 1

marekful
marekful

Reputation: 15351

Without code sample it's really just guessing, but my first impression is that you're trying to access some members of an object that was processed with json_decode. This will, by default, turn arrays into objects, to be more exact instances of PHP's StdClass. Either try accessing the members using object notation ($obj->member) or use the 2nd optional parameter to json_decode in which case the returned will be an associative array instead of an object.

See PHP doc for json_decode.

Upvotes: 1

Related Questions