FACT-Finder-Web-Components / shopware5-plugin

FACT-Finder® Web Components for Shopware 5
Other
1 stars 1 forks source link

FFWEB-1940: Export localized feed #37

Closed a-laurowski closed 3 years ago

a-laurowski commented 3 years ago
mwillner commented 3 years ago

Hi @a-laurowski,

the new TranslationService needs to be explicitly wired in our server environment, because otherwise Shopware_Components_Translation can not be found or collides with other plugins:

PHP Fatal error:  Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "OmikronFactfinder\Components\Service\TranslationService": argument "$translationComponent" of method "__construct()" references class "Shopware_Components_Translation" but no such service exists. You should maybe alias this class to one of these existing services: "translation", "bestit_shopware_component_translation". in /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:37
Stack trace:
#0 /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php(60): Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass->processValue(Object(Symfony\Component\DependencyInjection\Definition), true)
#1 /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php(30): Sy...

To solve this issue, I updated the definition of the TranslationService in OmikronFactfinder/Ressources/services/components.xml to:

<service id="OmikronFactfinder\Components\Service\TranslationService">
            <argument type="service" id="shopware_storefront.context_service" />
            <argument type="service" id="translation" />
</service>
a-laurowski commented 3 years ago

Hi @a-laurowski,

the new TranslationService needs to be explicitly wired in our server environment, because otherwise Shopware_Components_Translation can not be found or collides with other plugins:

PHP Fatal error:  Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "OmikronFactfinder\Components\Service\TranslationService": argument "$translationComponent" of method "__construct()" references class "Shopware_Components_Translation" but no such service exists. You should maybe alias this class to one of these existing services: "translation", "bestit_shopware_component_translation". in /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:37
Stack trace:
#0 /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php(60): Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass->processValue(Object(Symfony\Component\DependencyInjection\Definition), true)
#1 /var/www/clients/client1/web6/web/htdocs/stage_ff/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php(30): Sy...

To solve this issue, I updated the definition of the TranslationService in OmikronFactfinder/Ressources/services/components.xml to:

<service id="OmikronFactfinder\Components\Service\TranslationService">
            <argument type="service" id="shopware_storefront.context_service" />
            <argument type="service" id="translation" />
</service>

Hi @mwillner Thanks for the feedback! To be honest i didn't have any problems with autowiring in TranslationService but i guess it shouldn't be a problem to explicitly define the service arguments. will test that and update the PR.

a-laurowski commented 3 years ago

The price display in the frontend is missing / not switching to the correct currency. Other than that it looks pretty ok, better than what SW does.

One thing: I would check if it possible to instantiate the price columns using a ProxyPass instead of doing it manually with an extra constructor argument. LIke that it is more flexible and extensible in the future.

@fmarangi Could you explain a little more that solution? I apparently don't get that approach yet. What i know: I can't tag PriceCurrency because the number of its instances is vary and depends on number of configured currencies. Neither i can't instantiate them in CompilerPass because i need a db_connection (to fetch information about the configured currencies) which is added later, after plugins are initialized .