3

I recently updated Magento 2 to v2.3.5 and the Categories have a problem.

If I click the Save button in any Category I receive this message Categories error after Saved

Argument 1 passed to
Magento\Catalog\Model\Category\FileInfo::removeStorePath() 
must be of the type String, array given, 
called in 
/home/adminpsol2016/public_html/vendor/magento/module-catalog/Model/Category/FileInfo.php on line 167
2
  • 1
    Did you find any solution to above issue? I am getting same error after upgrade to Magento2.4.0.-p1
    – Tejas Shah
    Dec 10, 2020 at 13:36
  • Hi everyone same issue I'm facing. please do share if anyone has a solution. Apr 6, 2021 at 13:22

4 Answers 4

1

I have fixed this via a plugin. This has happened after the upgrade of Magento2.3.5 to Magento 2.4 when we select multiple products using select all checkbox and save category. Here is what I did -
Added adminhtml/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Controller\Adminhtml\Category\Save">
    <plugin name="ControllerCategorySave" type="Vendor\Module\Plugin\CategoryPlugin" sortOrder="10"/>
</type>
</config>

create plugin file called - CategoryPlugin.php

<?php 
namespace Vendor\Module\Plugin;
 
class CategoryPlugin
{        
    public function beforeExecute(\Magento\Catalog\Controller\Adminhtml\Category\Save $subject)
    {
        $categoryPostData = $subject->getRequest()->getPostValue();      
        
        $products = json_decode($categoryPostData['category_products'], true);
         if(in_array("on",$products))
        {
            array_pop($products);
        }   
        $newValue = json_encode($products); 
        $subject->getRequest()->setPostValue('category_products', $newValue);   
       
        return $subject;       
    }
}
2
  • Can you please share the complete plugin code?
    – omerts
    Apr 26, 2021 at 9:47
  • @Tejas Shah we are getting an issue - undefined array key "category_products" in /var/www/html/xyz/app/code/Company/Vendor/Plugin/CategoryPlugin.php on line 10 [] [] Feb 20, 2023 at 9:55
1

Had the same issue after upgrading to 2.4. For me the solution was to delete the \Magento\Catalog\Setup\Patch\Data\UpdateCustomLayoutAttributes patch from the patch_list table

DELETE FROM 'patch_list' WHERE patch_name = 'Magento\Catalog\Setup\Patch\Data\UpdateCustomLayoutAttributes'

Then run:

bin/magento setup:upgrade

Credit to: https://magento.stackexchange.com/a/307171/88690

1
  • correct query is delete FROM patch_list WHERE patch_name = 'Magento\\Catalog\\Setup\\Patch\\Data\\UpdateCustomLayoutAttributes' Nov 16, 2022 at 12:54
0

@Tejas Shah I have the same issue in Magento 2.4.3 but with your solution I get the notice: Notice: Undefined index: category_products in /var/www/clients/client1/web2/web/mag2/app/code/Wrj/CategorySave/Plugin/CategoryPlugin.php on line 11

0

This comment in https://github.com/magento/magento2/issues/33770#issuecomment-1133744546 fixed it for me.

While the error on the category page says Fileinfo.php, if I look into system.log I can see Duplicate entry errors as described in the github thread.

Your Answer

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

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