vienthuong / shopware-php-sdk

A PHP SDK for Shopware 6 Admin API
MIT License
111 stars 43 forks source link

Error, when trying to receive SystemConfig Entity - $configurationValue is of wrong type. #29

Closed sfxon closed 2 years ago

sfxon commented 2 years ago

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.

vienthuong commented 2 years ago

Hi @sfxon Thanks for reporting it, I will check the issue and comeback to you soon

vienthuong commented 2 years ago

@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

sfxon commented 2 years ago

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.