Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-memo-ict committed Feb 26, 2024
2 parents db86ab5 + 6ae6c2d commit 336db6a
Show file tree
Hide file tree
Showing 32 changed files with 576 additions and 114 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 3.1.0
- Added new Belgium to Netherlands products for shipping and pickup points
- Added an ID/age check option for shipping and pickup points in the Netherlands
- Fixed an issue whereby the pickup point location code was not stored on the order. Affected all 3.0 versions.
- Fixes an issue when changing the shipping method in the administration would always select NL as the sender's country
- Added support for MariaDB versions older than 10.5.2
- If you've already tried installing the plugin on an older MariaDB version, then take these steps to remove the plugin data before trying to install the new version:
- Remove any database table starting with `postnl_` from the database
- Remove all entries from the `migration` database table where the `class` field starts with `PostNL\Shopware6`
- Optional: Remove the old plugin files first and refresh the plugin listing in the admin

# 3.0.2
- Fix an issue whereby selected delivery dates or pickup points were not stored.
- Added delivery date and send date to the admin order detail page again.
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 3.1.0
- Neue Produkte für Belgien zu den Niederlanden für Versand- und Abholstellen hinzugefügt
- Es wurde eine Option zur Überprüfung von ID/Alter für Versand- und Abholstellen in den Niederlanden hinzugefügt.
- Es wurde ein Problem behoben, bei dem der Code der Abholstelle nicht in der Bestellung gespeichert wurde. Dies betraf alle 3.0-Versionen.
- Behebt ein Problem, bei dem beim Ändern der Versandmethode in der Verwaltung immer NL als Land des Absenders ausgewählt wurde
- Unterstützung für MariaDB-Versionen älter als 10.5.2 wurde hinzugefügt.
- Wenn Sie bereits versucht haben, das Plugin auf einer älteren MariaDB-Version zu installieren, führen Sie diese Schritte aus, um die Plugin-Daten zu entfernen, bevor Sie versuchen, die neue Version zu installieren:
- Entfernen Sie alle Datenbanktabellen, die mit `postnl_` beginnen, aus der Datenbank
- Entfernen Sie alle Einträge aus der Datenbanktabelle `migration`, bei denen das Feld `class` mit `PostNL\Shopware6` beginnt
- Optional: Entfernen Sie zuerst die alten Plugin-Dateien und aktualisieren Sie die Plugin-Liste in der Verwaltung

# 3.0.2
- Behebung eines Problems, bei dem ausgewählte Lieferdaten oder Abholpunkte nicht gespeichert wurden.
- Das Lieferdatum und das Versanddatum wurden auf der administrativen Bestellungsdetailseite wieder hinzugefügt.
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG_nl-NL.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 3.1.0
- Nieuwe België naar Nederland-producten toegevoegd voor verzend- en afhaalpunten
- Een ID/leeftijdscontroleoptie toegevoegd voor verzend- en afhaalpunten in Nederland
- Probleem verholpen waarbij de locatiecode van het afhaalpunt niet werd opgeslagen in de bestelling. Dit betrof alle 3.0 versies.
- Verhelpt een probleem waarbij bij het wijzigen van de verzendmethode in de administratie altijd NL werd geselecteerd als het land van de afzender
- Ondersteuning toegevoegd voor MariaDB-versies ouder dan 10.5.2
- Als je al geprobeerd hebt de plugin te installeren op een oudere MariaDB versie, neem dan deze stappen om de plugin gegevens te verwijderen voordat je probeert de nieuwe versie te installeren:
- Verwijder elke database tabel die begint met `postnl_` uit de database
- Verwijder alle items uit de `migratie` database tabel waar het `klasse` veld begint met `PostNL\Shopware6`.
- Optioneel: Verwijder eerst de oude plugin bestanden en ververs de plugin lijst in de admin

# 3.0.2
- Probleem verholpen waarbij geselecteerde afleverdata of afhaalpunten niet werden opgeslagen.
- Afleverdatum en verzenddatum weer toegevoegd aan de admin order detailpagina.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "postnl/shopware6",
"description": "PostNL",
"type": "shopware-platform-plugin",
"version": "3.0.2",
"version": "3.1.0",
"license": "proprietary",
"authors": [
{
Expand Down
6 changes: 6 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

PLUGIN_NAME=PostNLShopware
PLUGIN_VERSION=`php -r 'echo json_decode(file_get_contents("$(PLUGIN_NAME)/composer.json"))->version;'`
RELEASE_DIR=/var/www/html/.plugins/

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -94,10 +95,15 @@ release: ## Create a new release
@make install
@make build
@make zip
@make copy-release

zip: ## Creates a new ZIP package
@php update-composer-require.php --shopware=">=6.5.2 <6.6" --env=prod --admin --storefront
@cd .. && echo "Creating Zip file $(PLUGIN_NAME)-$(PLUGIN_VERSION).zip\n"
@cd .. && rm -rf $(PLUGIN_NAME)-$(PLUGIN_VERSION).zip
@cd .. && zip -qq -r -0 $(PLUGIN_NAME)-$(PLUGIN_VERSION).zip $(PLUGIN_NAME)/ -x@$(PLUGIN_NAME)/zip.exclude.lst
@php update-composer-require.php --shopware=">=6.5.2 <6.6" --env=dev --admin --storefront

copy-release: ## Copies it to the releases directory
@mkdir -p $(RELEASE_DIR)$(PLUGIN_NAME)
@cd .. && cp -f $(PLUGIN_NAME)-$(PLUGIN_VERSION).zip $(RELEASE_DIR)$(PLUGIN_NAME)/$(PLUGIN_NAME)-$(PLUGIN_VERSION).zip
6 changes: 4 additions & 2 deletions src/Controller/Api/ShipmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public function determineZones(QueryDataBag $data, Context $context): JsonRespon
{
$orderIds = $data->get('orderIds', new QueryDataBag())->all();

$zones = $this->shipmentFacade->determineZones($orderIds, $context);
$sourceZones = $this->shipmentFacade->determineSourceZones($orderIds, $context);
$destinationZones = $this->shipmentFacade->determineDestinationZones($orderIds, $context);

return $this->json([
'zones' => $zones,
'source' => $sourceZones,
'destination' => $destinationZones,
]);
}

Expand Down
53 changes: 43 additions & 10 deletions src/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class Defaults
const PRODUCT_SHIPMENT_BE_BE = self::PRODUCT_SHIPMENT_BE_BE_4960;
const PRODUCT_PICKUP_BE_BE = self::PRODUCT_PICKUP_BE_BE_4880;

const PRODUCT_SHIPMENT_BE_NL = self::PRODUCT_SHIPMENT_BE_NL_4890;
const PRODUCT_PICKUP_BE_NL = self::PRODUCT_PICKUP_BE_NL_4898;

const PRODUCT_SHIPMENT_BE_EU = self::PRODUCT_SHIPMENT_BE_EU_4907_005_025;
const PRODUCT_SHIPMENT_BE_GLOBAL = self::PRODUCT_SHIPMENT_BE_GLOBAL_4909_005_025;
//endregion
Expand Down Expand Up @@ -143,7 +146,7 @@ class Defaults
// BE->BE, Verzending, niet bij buren bezorgen, verzekerd
const PRODUCT_SHIPMENT_BE_BE_4965 = "76128ef0531645d4a93979f7e58be30f";

// BE->BE, Pickup,verzekerd
// BE->BE, Pickup, verzekerd
const PRODUCT_PICKUP_BE_BE_4878 = "7108d13a1c104ec3a3b0b661c9436186";

// BE->BE, Pickup
Expand Down Expand Up @@ -234,16 +237,46 @@ class Defaults
//endregion
//endregion

//region V3.1.0 Identifiers
/**
* V3.1.0
*/

//region New BE -> NL productcodes

// BE->NL, Verzending
const PRODUCT_SHIPMENT_BE_NL_4890 = "45432c40e63f4ec79aa230c0bed4c0e2";

// BE->NL, Verzending, handtekening
const PRODUCT_SHIPMENT_BE_NL_4891 = "6014c5955e0c448ab27c37142f0bfdac";

// BE->NL, Verzending, niet bij buren bezorgen
const PRODUCT_SHIPMENT_BE_NL_4893 = "be49eed381bc4b7e935a39926273717c";

// BE->NL, Verzending, handtekening, niet bij buren bezorgen
const PRODUCT_SHIPMENT_BE_NL_4894 = "47ab691cd2504280b1af6e6e002c94f2";

// BE->NL, Verzending, handtekening, retour b.g.g.
const PRODUCT_SHIPMENT_BE_NL_4896 = "dac322ddf7db4e3c95e7ba915b21f15c";

// BE->NL, Verzending, verzekerd, handtekening
const PRODUCT_SHIPMENT_BE_NL_4897 = "2cc40e192141468cb57852305596ad37";

// BE->NL, Pickup, handtekening
const PRODUCT_PICKUP_BE_NL_4898 = "bc5f4a5e53df412b80600eaa68d7d335";
//endregion

//region ID Check products initial

// NL->NL, Verzending, verzekerd, handtekening
const PRODUCT_SHIPMENT_NL_NL_3438 = "aa67b151850646849464e633d4a14beb";

// NL->NL, Pickup, handtekening
const PRODUCT_PICKUP_NL_NL_3571 = "91cca8b821f4413dad3f3133b7b5dffe";
//endregion
//endregion

//region Placeholder identifiers
// const PLACEHOLDER = "45432c40e63f4ec79aa230c0bed4c0e2";
// const PLACEHOLDER = "6014c5955e0c448ab27c37142f0bfdac";
// const PLACEHOLDER = "be49eed381bc4b7e935a39926273717c";
// const PLACEHOLDER = "47ab691cd2504280b1af6e6e002c94f2";
// const PLACEHOLDER = "dac322ddf7db4e3c95e7ba915b21f15c";
// const PLACEHOLDER = "2cc40e192141468cb57852305596ad37";
// const PLACEHOLDER = "bc5f4a5e53df412b80600eaa68d7d335";
// const PLACEHOLDER = "aa67b151850646849464e633d4a14beb";
// const PLACEHOLDER = "91cca8b821f4413dad3f3133b7b5dffe";
// const PLACEHOLDER = "596c345d25684e729909175ed50c9897";
// const PLACEHOLDER = "cbd12ab384534364919140e09f1c77bb";
// const PLACEHOLDER = "01d9979b809b4458b0e9ab16051a3570";
Expand Down
12 changes: 11 additions & 1 deletion src/Facade/ProductFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ public function selectProduct(
$changeSet,
$context
);
// Should always only have one.

// Should have only one, if the combinations are available
$filteredProducts = $this->productService->filterProductsByFlags($products, $filters);

$product = $filteredProducts->first();
Expand All @@ -209,6 +210,15 @@ public function selectProduct(
return $product;
}

// Combination was not available, try to filter by the change set. Can have multiple
$filteredProducts = $this->productService->filterProductsByChangeSet($products, $changeSet);

$product = $filteredProducts->first();

if ($product instanceof ProductEntity) {
return $product;
}

// TODO Exception
throw new \Exception('Could not select product');
}
Expand Down
23 changes: 22 additions & 1 deletion src/Facade/ShipmentFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,28 @@ public function generateBarcodes(array $orderIds, Context $context): array
* @return string[]
* @throws \Exception
*/
public function determineZones(array $orderIds, Context $context): array
public function determineSourceZones(array $orderIds, Context $context): array
{
$sourceZones = [];

foreach ($orderIds as $orderId) {
$order = $this->orderService->getOrder($orderId, $context);

$config = $this->configService->getConfiguration($order->getSalesChannelId(), $context);

$sourceZones[] = $config->getSenderAddress()->getCountrycode();
}

return array_values(array_unique($sourceZones));
}

/**
* @param string[] $orderIds
* @param Context $context
* @return string[]
* @throws \Exception
*/
public function determineDestinationZones(array $orderIds, Context $context): array
{
$deliveryZones = [];

Expand Down
18 changes: 14 additions & 4 deletions src/Migration/Migration1674128763RenameOptionTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ public function update(Connection $connection): void
RENAME TABLE `postnl_product_option_mapping` TO `postnl_product_option_required_mapping`;
ALTER TABLE `postnl_option_translation` CHANGE `postnl_product_option_id` `postnl_option_id` BINARY(16) NOT NULL;
ALTER TABLE `postnl_option_translation` RENAME INDEX `fk.postnl_product_option_translation.product_option_id` TO `fk.postnl_option_translation.postnl_option_id`;
ALTER TABLE `postnl_option_translation` RENAME INDEX `fk.postnl_product_option_translation.language_id` TO `fk.postnl_option_translation.language_id`;
-- MariaDB <10.5.2 compatibility
-- ALTER TABLE `postnl_option_translation` RENAME INDEX `fk.postnl_product_option_translation.product_option_id` TO `fk.postnl_option_translation.postnl_option_id`;
-- ALTER TABLE `postnl_option_translation` RENAME INDEX `fk.postnl_product_option_translation.language_id` TO `fk.postnl_option_translation.language_id`;
ALTER TABLE `postnl_option_translation` ADD INDEX `fk.postnl_option_translation.postnl_option_id` (`postnl_option_id`);
ALTER TABLE `postnl_option_translation` ADD INDEX `fk.postnl_option_translation.language_id` (`language_id`);
ALTER TABLE `postnl_option_translation` DROP INDEX `fk.postnl_product_option_translation.product_option_id`;
ALTER TABLE `postnl_option_translation` DROP INDEX `fk.postnl_product_option_translation.language_id`;
ALTER TABLE `postnl_product_option_required_mapping` CHANGE `product_option_id` `option_id` BINARY(16) NOT NULL;
ALTER TABLE `postnl_product_option_required_mapping` RENAME INDEX `fk.postnl_product_option_mapping.product_id` TO `fk.postnl_product_option_required_mapping.product_id`;
ALTER TABLE `postnl_product_option_required_mapping` RENAME INDEX `fk.postnl_product_option_mapping.product_option_id` TO `fk.postnl_product_option_required_mapping.option_id`;
-- MariaDB <10.5.2 compatibility
-- ALTER TABLE `postnl_product_option_required_mapping` RENAME INDEX `fk.postnl_product_option_mapping.product_id` TO `fk.postnl_product_option_required_mapping.product_id`;
-- ALTER TABLE `postnl_product_option_required_mapping` RENAME INDEX `fk.postnl_product_option_mapping.product_option_id` TO `fk.postnl_product_option_required_mapping.option_id`;
ALTER TABLE `postnl_product_option_required_mapping` ADD INDEX `fk.postnl_product_option_required_mapping.product_id` (`product_id`);
ALTER TABLE `postnl_product_option_required_mapping` ADD INDEX `fk.postnl_product_option_required_mapping.option_id` (`option_id`);
ALTER TABLE `postnl_product_option_required_mapping` DROP INDEX `fk.postnl_product_option_mapping.product_id`;
ALTER TABLE `postnl_product_option_required_mapping` DROP INDEX `fk.postnl_product_option_mapping.product_option_id`;
SQL;

$this->execute($connection, $sql);
Expand Down
131 changes: 131 additions & 0 deletions src/Migration/Migration1708424779CreateV3_1_0BelgianProducts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php declare(strict_types=1);

namespace PostNL\Shopware6\Migration;

use Doctrine\DBAL\Connection;
use PostNL\Shopware6\Component\Migration\ProductMigration;
use PostNL\Shopware6\Defaults;
use PostNL\Shopware6\Entity\Product\ProductDefinition;
use PostNL\Shopware6\Service\PostNL\Delivery\DeliveryType;
use PostNL\Shopware6\Service\PostNL\Delivery\Zone\Zone;
use Shopware\Core\Framework\Migration\MigrationStep;
use Shopware\Core\Framework\Uuid\Uuid;

class Migration1708424779CreateV3_1_0BelgianProducts extends ProductMigration
{
public function getCreationTimestamp(): int
{
return 1708424779;
}

public function update(Connection $connection): void
{
$products = [
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4890),
'product_code_delivery' => '4890',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 0,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 0,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 0,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4891),
'product_code_delivery' => '4891',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 0,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 0,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 1,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4893),
'product_code_delivery' => '4893',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 1,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 0,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 0,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4894),
'product_code_delivery' => '4894',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 1,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 0,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 1,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4896),
'product_code_delivery' => '4896',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 1,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 1,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 1,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_SHIPMENT_BE_NL_4897),
'product_code_delivery' => '4897',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::SHIPMENT,
ProductDefinition::STOR_HOME_ALONE => 1,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => 0,
ProductDefinition::STOR_INSURANCE => 1,
ProductDefinition::STOR_SIGNATURE => 1,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => null,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
[
'id' => Uuid::fromHexToBytes(Defaults::PRODUCT_PICKUP_BE_NL_4898),
'product_code_delivery' => '4898',
'source_zone' => Zone::BE,
'destination_zone' => Zone::NL,
'delivery_type' => DeliveryType::PICKUP,
ProductDefinition::STOR_HOME_ALONE => null,
ProductDefinition::STOR_RETURN_IF_NOT_HOME => null,
ProductDefinition::STOR_INSURANCE => 0,
ProductDefinition::STOR_SIGNATURE => 1,
ProductDefinition::STOR_AGE_CHECK => 0,
ProductDefinition::STOR_NOTIFICATION => 0,
ProductDefinition::STOR_TRACK_AND_TRACE => null,
],
];

$this->insertProducts($connection, $products);
}

public function updateDestructive(Connection $connection): void
{
// implement update destructive
}
}
Loading

0 comments on commit 336db6a

Please sign in to comment.