Error, when trying to receive SystemConfig Entity - $configurationValue is of wrong type.
sfxon opened this issue · 3 comments
When try to read one entry in the system configuration, like that:
$systemConfigRepository = RepositoryFactory::create(SystemConfigDefinition::ENTITY_NAME);
$criteria = new Criteria();
$criteria->setLimit(1);
$criteria->addFilter(new EqualsFilter('configurationKey', 'MyFavApiTest.config.receiver'));
$result = $systemConfigRepository->search($criteria, $context);
I get an error:
Cannot assign string to property Vin\ShopwareSdk\Data\Entity\SystemConfig\SystemConfigEntity::$configurationValue of type ?array
I changed configurationValue in SystemConfigEntity to data-type of string, and it is working.
Is this really an error, or am I doing something wrong?
Setup:
Shop: Shopware 6.4.8.1 on PHP 8
App: Symfony 6 on PHP 8
The one that produces the error, is the app.
Thanks for all the good work, so far.
It's a pleasure to work with that library.
Hi @sfxon
Thanks for reporting it, I will check the issue and comeback to you soon
@sfxon Hi, I investigated the issue, it's actually an issue in the core that the return type is not matched with the actual value. I adapted the hot-fix in the latest SDK version
But the more valid way to retrieve system config is using this service instead so the error will not happend https://github.com/vienthuong/shopware-php-sdk/blob/master/src/Service/SystemConfigService.php
Fantastic work. Thank you very much.
I will switch to SystemConfigService shortly, I think.
Didn't notice, there's even a finished service for that.