1

Please check below error:

Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Cannot use string offset as an array in /vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0

I can see the above error when I go to the admin > Catalog > Manage Category and choose any category to edit.

Please help me if you face any kind of this issues?

Thanks in advance!

5
  • did you make any changes in core modules.?
    – Ask Xah
    Oct 10, 2018 at 10:20
  • In your custom construct argument are different so this issue occur. First check after removing generated folder. if it will not work check which module's code affected it Oct 10, 2018 at 10:25
  • @AskBytes No, I didn't make any changes in core files
    – Rajan Soni
    Oct 10, 2018 at 10:32
  • Hi, @RutveeSojitra I have setup 2 environment 1st for production and 2nd is the clone of production as staging. That same error I didn't get on staging and I got the above error on production. I also tried with your answers but it's not working can you please help me to fix that error with your great suggestions. Thanks!
    – Rajan Soni
    Oct 15, 2018 at 7:29
  • Hi @RutveeSojitra see I got the answer
    – Rajan Soni
    Nov 22, 2018 at 10:10

2 Answers 2

1

I just fixed the above mention issue which I mention in my question.

I got the error is actually coming from the Core files.

Just go to the file using below path: > /vendor/magento/module-catalog/Model/Category/DataProvider.php

Should use $attributeCode as lines 495 & 496 rather than hardcoded ['image']

Like below code

$categoryData[$attributeCode][0]['size'] = isset($stat) ? $stat['size'] : 0;
$categoryData[$attributeCode][0]['type'] = $mime;

I hope its working for you as well.

1

you need to add this in your di.xml in tag

type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult"

Your di.xml will be like this

  <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="vendor\module\Model\ResourceModel\Region\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">you_table_name</argument>
            <argument name="resourceModel" xsi:type="string">vendor\module\Model\ResourceModel\Region</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="your_table_name" xsi:type="string">vendor\module\Model\ResourceModel\Region\Collection</item>
            </argument>
        </arguments>
    </type>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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