From 2735355da10585fd35d54117ac1008314fafd471 Mon Sep 17 00:00:00 2001 From: hung mac Date: Thu, 19 Nov 2020 01:13:03 +0700 Subject: [PATCH] Hotfix to send the download email on Shopware version 6.3.3.0 --- CHANGELOG_de-DE.md | 3 +++ CHANGELOG_en-GB.md | 3 +++ composer.json | 2 +- src/Resources/config/services.xml | 1 + src/Service/EsdMailService.php | 26 +++++++++++++++++++++++++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index d8ca96c..e17ccef 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,6 @@ +# 1.2.8 +* Ein Hotfix zum Senden der Download-E-Mail in der Shopware version 6.3.3.0 wurde erstellt + # 1.2.7 * fixed a bug with the general terms and condition checkbox during the checkout diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index 36cbcab..9772479 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,6 @@ +# 1.2.8 +* Made a hotfix to send the download email on Shopware version 6.3.3.0 + # 1.2.7 * fixed a bug with the general terms and condition checkbox during the checkout diff --git a/composer.json b/composer.json index e50c85e..95161ec 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description":"ESD / Download plugin", "type":"shopware-platform-plugin", "keywords": ["esd", "download"], - "version":"1.2.7", + "version":"1.2.8", "license":"proprietary", "authors":[ { diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index e2350ab..7da6d89 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -106,6 +106,7 @@ + diff --git a/src/Service/EsdMailService.php b/src/Service/EsdMailService.php index b369afb..3b46b68 100644 --- a/src/Service/EsdMailService.php +++ b/src/Service/EsdMailService.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; +use Shopware\Core\Framework\Store\Services\StoreService; use Shopware\Core\Framework\Validation\DataBag\DataBag; use Shopware\Core\System\SystemConfig\SystemConfigService; use Symfony\Component\Messenger\MessageBusInterface; @@ -37,16 +38,23 @@ class EsdMailService */ private $messageBus; + /** + * @var StoreService + */ + private $storeService; + public function __construct( SystemConfigService $systemConfigService, EntityRepositoryInterface $mailTemplateRepository, EsdService $esdService, - MessageBusInterface $messageBus + MessageBusInterface $messageBus, + StoreService $storeService ) { $this->systemConfigService = $systemConfigService; $this->mailTemplateRepository = $mailTemplateRepository; $this->esdService = $esdService; $this->messageBus = $messageBus; + $this->storeService = $storeService; } public function sendMailDownload( @@ -135,6 +143,12 @@ public function sendMail( private function getMailTemplate(Context $context, string $technicalName, OrderEntity $order): ?MailTemplateEntity { + // TODO remove it when finalizing the official patch + $shopwareVersion = $this->storeService->getShopwareVersion(); + if ($shopwareVersion >= '6.3.3.0') { + return $this->getMailTemplateHotFixVersion6330($context, $technicalName); + } + $criteria = new Criteria(); $criteria->addAssociation('salesChannels'); $criteria->addFilter(new EqualsFilter('mailTemplateType.technicalName', $technicalName)); @@ -144,6 +158,16 @@ private function getMailTemplate(Context $context, string $technicalName, OrderE return $this->mailTemplateRepository->search($criteria, $context)->first(); } + // TODO remove it when finalizing the official patch + private function getMailTemplateHotFixVersion6330(Context $context, string $technicalName): ?MailTemplateEntity + { + $criteria = new Criteria(); + $criteria->addFilter(new EqualsFilter('mailTemplateType.technicalName', $technicalName)); + $criteria->setLimit(1); + + return $this->mailTemplateRepository->search($criteria, $context)->first(); + } + private function getSystemConfig(string $name): bool { $isSendDownloadConfirmation = $this->systemConfigService->get('SasEsd.config.' . $name);