Skip to content

Commit

Permalink
Merge branch 'hotfix/send-mail-on-vesion-6330' into 'master'
Browse files Browse the repository at this point in the history
Hotfix to send the download email on Shopware version 6.3.3.0

See merge request shape-and-shift/plugins/shopware-esd!18
  • Loading branch information
ChristopherDosin committed Nov 20, 2020
2 parents 99ebd8e + 2735355 commit ea9f64a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":[
{
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<argument type="service" id="mail_template.repository"/>
<argument type="service" id="Sas\Esd\Service\EsdService"/>
<argument type="service" id="messenger.bus.shopware" />
<argument type="service" id="Shopware\Core\Framework\Store\Services\StoreService" />
</service>

<service id="Sas\Esd\Service\EsdDownloadService">
Expand Down
26 changes: 25 additions & 1 deletion src/Service/EsdMailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down

0 comments on commit ea9f64a

Please sign in to comment.