this is the error I get with my Magento 2 module, in my logs:

Warning: Illegal string offset 'itemID' in /a/www/vhosts/domain.com/mage2.domain.com/deploy003/app/code/Maurisource/Lightspeed/Helper/Catalog/Product/Configurable.php on line 68

This is line:68 it's referring to:

foreach ($rawData['Items']['Item'] as $item) {
    $simpleProductLightspeedId[] = $item['itemID'];

This is the output of debug.log


[2017-11-22 21:43:36] main.DEBUG: [{"itemID":"14","systemSku":"210000000020","defaultCost":"0","avgCost":"0","discountable":"true","tax":"true","archived":"false","itemType":"default","serialized":"false","description":"manesh-matrix-color a b c","modelYear":"0","upc":"","ean":"","customSku":"","manufacturerSku":"","createTime":"2016-05-02T18:33:46+00:00","timeStamp":"2016-06-02T19:22:26+00:00","publishToEcom":"false","categoryID":"2","taxClassID":"1","departmentID":"0","itemMatrixID":"3","itemAttributesID":"3","manufacturerID":"5","noteID":"16","seasonID":"0","defaultVendorID":"0","itemECommerceID":"0","Prices":{"ItemPrice":[{"amount":"788","useTypeID":"1","useType":"Default"},{"amount":"788","useTypeID":"2","useType":"MSRP"},{"amount":"788","useTypeID":"3","useType":"Online"}]}},

I think this error suggests that $rawData['Items']['Item'] is not an array. But I'm not sure what's wrong here, any hints?

  • print_r($rawData['Items']['Item']).. print your object and see what you are getting in there – Abhishek Panchal Nov 22 '17 at 18:35
  • @AbhishekPanchal Here's what's printed out – maurisource web Nov 22 '17 at 22:29
  • the things which you access are not array, So it show this error. – Dhiren Vasoya Nov 23 '17 at 12:18
  • @DhirenVasoya - Correct. But any hints on how to access 'itemID' ? Since Magento brackets are considered as array [ ] – maurisource web Nov 23 '17 at 15:01

before the foreach loop I used the following code to fix the issue:

    $rawData['Items']['Item'][] = $rawData['Items']['Item'];

You can try this code.

$jsonarray = json_decode(json_encode($rawData['Items']['Item'])); 
foreach ($jsonarray as $item) 
    $simpleProductLightspeedId[] = $item['itemID'];
  • Hi this doens't work. I still get the same error as above – maurisource web Nov 29 '17 at 23:53
  • Have you $jsonarray log this array? what it return? – Dhiren Vasoya Nov 30 '17 at 2:58

I traced the code

public function getOptionText($value)
    $options = $this->getAllOptions();
    // Fixed for tax_class_id and custom_design
    if (sizeof($options) > 0) {
        foreach ($options as $option) {
            if (isset($option['value']) && $option['value'] == $value) {
                return isset($option['label']) ? $option['label'] : $option['value'];
    // End
    if (isset($options[$value])) {
        return $options[$value];
    return false;

on AbstractSource.php

the proplem is array variable passed to the isset function should be referecne variable.

ignore warning on php ini or pass the parameter to the new variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.