Jump to content

Cannot use object of type stdClass as array


Recommended Posts

Hello,

I've noticed that my review module stopped to send reminder emails to my customers. When I start cron job manually I'm getting #500 error. Debug mode shows a message like in the attachment.

The Reminder.php line 254:

253:                foreach ($data_task as $k1 => $product) {
254:                    if (in_array($product['id_product'], $tmp_array)) {
255:                        unset($data_task[$k1]);
...                         continue;
                        }
                        $text .= $this->generateProductTemplate($product, $data_translate);
                        $tmp_array[] = $product['id_product'];
                    }
                    $param = [
                        'subject' => $subject,
                        'email' => $task['email'],
                        'order_id' => $task['order_id'],
                        'id_shop' => $task['id_shop'],
                        'id_lang' => $task['id_lang'],
                        'vars' => [
                            '{products_text}' => $text,
                            '{orderid}' => $task['order_id'],
                            '{lastname}' => $task['lastname'],
                            '{firstname}' => $task['firstname'],
                            '{short_link}' => $short_link,
                        ],
                    ];

Unfortunately I cannot check when precisely it stopped to work, but I think it was more or less after I updated Presta from 1.7.8.10 to 1.7.8.11

 

What could go wrong?

001.png

Edited by michal88sjz (see edit history)
Link to comment
Share on other sites

Hello,

The issue is that you are trying to access the 'id_product' property as $product['id_product'], but that object is an instance of stdClass. For stdClass, you need to access them as $poduct->id_product.

The problem is most likely in the $data_task array. For some reason, its content is an array of objects instead of an array of arrays. Unfortunately, I cannot comment more on it, as I don't know how are you building it.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...