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!

  • did you make any changes in core modules.? – Ask Bytes Oct 10 '18 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 – Rutvee Sojitra Oct 10 '18 at 10:25
  • @AskBytes No, I didn't make any changes in core files – Rajan Soni Oct 10 '18 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 '18 at 7:29
  • Hi @RutveeSojitra see I got the answer – Rajan Soni Nov 22 '18 at 10:10
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.

0

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, privacy policy and cookie policy

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