0
Fatal error: Uncaught Error: Call to a member function serialize() on null in /vendor/magento/module-swatches/Helper/Data.php:162

Stack trace: #0 /vendor/magento/module-swatches/Model/Plugin/EavAttribute.php(100):

Magento\Swatches\Helper\Data->assembleAdditionalDataEavAttribute(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor)) #1 

/vendor/magento/framework/Interception/Interceptor.php(121): 

Magento\Swatches\Model\Plugin\EavAttribute->beforeBeforeSave(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor)) 

#2 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->Magento\Framework\Interception\{closure}()

#3 /generated/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute/Interceptor.php(26): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->___ in /vendor/magento/module-swatches/Helper/Data.php on line 162

please help and suggest possible solutions my magento version is 2.3.0

0

Upgrade your magento with latest version of Magento 2 so error will automatically solved

php -d memory_limit=-1 bin/magento maintenance:enable

php -d memory_limit=-1 bin/magento deploy:mode:show

php -d memory_limit=-1 bin/magento deploy:mode:set developer

php -d memory_limit=-1 composer.phar require magento/product-community-edition=2.3.4 --no-update

php -d memory_limit=-1 composer.phar require --dev allure-framework/allure-phpunit:~1.2.0 friendsofphp/php-cs-fixer:~2.14.0 lusitanian/oauth:~0.8.10 magento/magento-coding-standard:~3.0.0 magento/magento2-functional-testing-framework:2.4.3 pdepend/pdepend:2.5.2 phpmd/phpmd:@stable phpunit/phpunit:~6.5.0 sebastian/phpcpd:~3.0.0 squizlabs/php_codesniffer:~3.4.0 --sort-packages --no-update

php -d memory_limit=-1 composer.phar remove --dev sjparkinson/static-review fabpot/php-cs-fixer --no-update

php -d memory_limit=-1 composer.phar update
| improve this answer | |
  • 1
    Can you please point only code changes solution with which we can make this working in same magento 2 version without upgrade – Ram singh Mar 12 at 11:24
  • Why you are working on old magento there are no bug for upgrade latest version of magento – user53909 Mar 12 at 11:44
  • I need to solve the issue as 2.3.0 is not very old version – Ram singh Mar 12 at 12:09
0

Finally i solved the error

$serializer variable was checked in constructor of the class vendor/magento/module-swatches/Helper/Data.php to be initialised with the help of ObjectManager if found uninitialised, but ternary operator in php ? : is not evaluating null property properly.

so i added

if(null == $this->serializer) { $this->serializer = ObjectManager::getInstance()->create(Json::class); }

before

$attribute->setData('additional_data', $this->serializer->serialize($additionalData)); 
| improve this answer | |

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.