Skip to content

Commit

Permalink
Merge pull request #19 from Shape-and-Shift/1.4.2
Browse files Browse the repository at this point in the history
Upgraded to be compatible with Shopware version 6.4
  • Loading branch information
ChristopherDosin authored May 5, 2021
2 parents 0851b3c + 1085e71 commit 138362d
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.2
* Aktualisiert, um mit Version 6.4 kompatibel zu sein.
* Mail senden behoben

# 1.4.1
* Korrigierte js-Kompressionsdatei für Version 1.4.0

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.2
* Upgraded to be compatible with version 6.4
* Fixed send mail

# 1.4.1
* Fixed js compress file for version 1.4.0

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.4.1",
"version":"1.4.2",
"license":"proprietary",
"authors":[
{
Expand Down
9 changes: 9 additions & 0 deletions src/Event/EsdDownloadPaymentStatusPaidEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public function getEsdOrderListIds(): array
return $this->templateData['esdOrderListIds'];
}

public function getEsdMediaFiles(): array
{
if (empty($this->templateData['esdMediaFiles'])) {
return [];
}

return $this->templateData['esdMediaFiles'];
}

public static function getAvailableData(): EventDataCollection
{
return (new EventDataCollection())
Expand Down
15 changes: 11 additions & 4 deletions src/Message/SendMailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

namespace Sas\Esd\Message;

use Shopware\Core\Content\MailTemplate\Service\MailService;
use Shopware\Core\Content\Mail\Service\MailService as MailService;
use Shopware\Core\Content\MailTemplate\Service\MailService as MailServiceV63;

use Shopware\Core\Framework\MessageQueue\Handler\AbstractMessageHandler;

class SendMailHandler extends AbstractMessageHandler
{
/**
* @var MailService
* @var MailService|MailServiceV63|null
*/
private $mailService;

public function __construct(MailService $mailService)
public function __construct(?MailService $mailService, ?MailServiceV63 $mailServiceV63)
{
$this->mailService = $mailService;
if ($mailServiceV63) {
$this->mailService = $mailServiceV63;
} else {
$this->mailService = $mailService;
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "~scss/variables";
$sw-products-variants-generated-variants-toolbar-background: #f8f9fa;
$sw-products-variants-generated-variants-toolbar-border: $color-steam-cloud;
$sw-products-variants-generated-variants-toolbar-border: $color-gray-300;

.sas-esd-serial-overview {
.sw-card__content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ Component.register('sas-product-detail-esd', {
},

onDeleteSelectedMedia() {
Object.keys(this.selectedItems).forEach((mediaId) => {
this.onDeleteMediaItem(mediaId);
Object.values(this.selectedItems).forEach((item) => {
if (item.media && item.media.id) {
this.onDeleteMediaItem(item.media.id);
}
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:allowColumnEdit="true"
:allowInlineEdit="true"
:compactMode="false"
@selection-change="onSelectionChanged"
@selection-change="(esdMedia) => onSelectionChanged(esdMedia)"
@inline-edit-save="onInlineEditSave"
:isLoading="isStoreLoading || isLoading">
<template #preview-fileName="{ item }">
Expand All @@ -53,7 +53,7 @@
</template>

<template #actions="{ item }">
<sw-context-menu-item variant="danger" @click="onDeleteMediaItem(item.id)">
<sw-context-menu-item variant="danger" @click="onDeleteMediaItem(item.media.id)">
{{ $tc('global.default.delete') }}
</sw-context-menu-item>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
}

.sw-data-grid__table {
border-top: solid 1px $color-steam-cloud;
border-bottom: solid 1px $color-steam-cloud;
border-top: solid 1px $color-gray-300;
border-bottom: solid 1px $color-gray-300;
}

.sw-field--switch,
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@

<!-- Message -->
<service id="Sas\Esd\Message\SendMailHandler">
<argument type="service" id="Shopware\Core\Content\MailTemplate\Service\MailService"/>
<argument type="service" id="Shopware\Core\Content\MailTemplate\Service\MailService" on-invalid="null"/>
<argument type="service" id="Shopware\Core\Content\Mail\Service\MailService" on-invalid="null"/>
<tag name="messenger.message_handler"/>
</service>

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/administration/js/sas-esd.js

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions src/SasEsd.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,27 @@ protected function dropDatabaseTable(): void
/** @var Connection $connection */
$connection = $this->container->get(Connection::class);

$connection->executeQuery('SET FOREIGN_KEY_CHECKS=0;');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd`');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd_order`');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd_serial`');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd_media`');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd_download_history`');
$connection->executeQuery('DROP TABLE IF EXISTS `sas_product_esd_video`');
$connection->executeUpdate('ALTER TABLE `product` DROP COLUMN `esd`');
$connection->executeQuery('SET FOREIGN_KEY_CHECKS=1;');
if (method_exists($connection,'executeStatement')) {
$connection->executeStatement('SET FOREIGN_KEY_CHECKS=0;');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd`');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd_order`');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd_serial`');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd_media`');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd_download_history`');
$connection->executeStatement('DROP TABLE IF EXISTS `sas_product_esd_video`');
$connection->executeStatement('ALTER TABLE `product` DROP COLUMN `esd`');
$connection->executeStatement('SET FOREIGN_KEY_CHECKS=1;');
} else {
$connection->exec('SET FOREIGN_KEY_CHECKS=0;');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd`');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd_order`');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd_serial`');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd_media`');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd_download_history`');
$connection->exec('DROP TABLE IF EXISTS `sas_product_esd_video`');
$connection->exec('ALTER TABLE `product` DROP COLUMN `esd`');
$connection->exec('SET FOREIGN_KEY_CHECKS=1;');
}
}

private function rmdirRecursive($dir): void
Expand Down
4 changes: 4 additions & 0 deletions src/Service/EsdOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public function fetchSerials(EsdEntity $esd, Context $context): ?EntitySearchRes
public function isEsdOrder(OrderEntity $order): bool
{
foreach ($order->getLineItems() as $lineItem) {
if (!$lineItem->getProduct()) {
continue;
}

/** @var EsdEntity $esd */
$esd = $lineItem->getProduct()->getExtension('esd');
if (empty($esd)) {
Expand Down

0 comments on commit 138362d

Please sign in to comment.