Magento 2.3.0 error while changing dropdown attribute to visual swatches
-
12-04-2021 - |
Frage
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
Lösung 2
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));
Andere Tipps
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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange