fbpx

Blog

SOFTLOFT / Magento  / Magento migration issue. Can’t edit a product in admin panel Illegal offset type in isset or empty

Magento migration issue. Can’t edit a product in admin panel Illegal offset type in isset or empty

The error and the solution of the problem have been obtained as a result of migration from Magento 1 (1.9. *) To Magento 2 (2.3.5-p1), but also can be after updating Magento, for example from version 2.2.7 to version 2.3.2.

Main causes:

  • – Migration from M1 to M2
  • – Update M2

How to reproduce

Go to the admin panel, try to open any product for editing or viewing, you get an error message

Warning: Illegal offset type in isset or empty in /vendor/magento/module-ui/Config/Reader/Definition/Data.php on line 126

How to debug

Open the file vendor/magento/module-ui/Config/Reader/Definition/Data.php line 126

From the description of the function, it is clear that $key – there must be a string, but an array comes

    /**
     * Get config value by key
     *
     * @param string $key
     * @param mixed $default
     * @return array|mixed|null
     */
    public function get($key, $default = null)
    {
        return isset($this->data[$key]) ? $this->data[$key] : $default;
    }

If debugging $key you can see something like [‘fieldset’, ‘fieldset’]
(if that I do not use php xdebug, it’s a long time 🙂 )

What’s the solution

Hot-fix

it works, but don’t do it, never 🙂

But, you need to do this in order to understand what has changed in the admin panel. After the hotfix, editing the product became possible, but the name of one attribute group became [object] but it must be “Configurable”

if (is_array($key) === true) {
   $key = 'fieldset';
}

Need more information about the data – find the reason. Go to the class below and add logging $data

\Magento\Framework\View\Element\UiComponentFactory.php

protected function mergeMetadataItem(array $bundleComponents, array $metadata, $reverseMerge = false)
{
   //...
   // line 399
   // Debugging $data to log file
   if (is_array($data['arguments']['data']['config']['componentType'])) {
      file_put_contents('/app/var/log/1.log', print_r($data, true), 8);
   }
   //...
}

log -> Debug information

[data] => Array
(
    [config] => Array(
      [componentType] => Array
      (
        [0] => fieldset
        [1] => fieldset
      )

    [label] => Array(
      [ Magento\Framework\Phrase text] => Array(
        [0] => Configurable
        [1] => Configurations
    )
)

Most likely we have several components – groups with the same code.
Let’s open the eav_attribute_group table – it stores information about the groups in which the attributes are stored

Perform a search

SELECT * attribute_group_name WHERE attribute_group_name="Configurable"

Feel free to use our Services

The picture shows that we have 2 groups with the same code

What should be done

Make attribute_group_name unique. I changed configurable -> configurable

The problem is solved!

Sergey Vlasov

CTO and partner at SOFT LOFT, a 19-year-old software development house that's focused on E-Commerce solutions for our partners and clients.

Follow: