vienthuong / shopware-php-sdk

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

EntityHydrator does a schema call for each entity #35

Closed attrib closed 2 years ago

attrib commented 2 years ago

If a search call is done with a custom definition, there will be a schema call for each entity of the results.

The reason for this is, that the InfoService is instantiated for each entity.

https://github.com/vienthuong/shopware-php-sdk/blob/196268493addaaae52b20356641e622bf107bedd/src/Repository/Traits/EntityHydrator.php#L18-L22

The InfoService has a internal cache, but that cache is non static.

Either the InfoService needs to be a singleton or cached somewhere (RepositoryFactory?) or the cache inside InfoService needs to be static.

vienthuong commented 2 years ago

Hi, thanks for the suggestion, I'd take a look

vienthuong commented 2 years ago

Hi @attrib I added a simple internal cache for src/Repository/Traits/EntityHydrator.php in this MR https://github.com/vienthuong/shopware-php-sdk/pull/36/files. Feel free to have a look to see if it solve the caching issue?

attrib commented 2 years ago

Looks good, thanks for the fast response.