From 47ae16bf17e69306e72e0d0ae1f944153e4e16dc Mon Sep 17 00:00:00 2001 From: Fabiana Romagnoli Date: Mon, 6 Sep 2021 12:19:22 +0200 Subject: [PATCH 1/4] Add localized interfaces for brand, size and color --- .../Google/Shopping/ProductItemContext.php | 21 ++++++++++++++++--- src/Model/BrandAwareInterface.php | 4 ++++ src/Model/ColorAwareInterface.php | 4 ++++ src/Model/LocalizedBrandAwareInterface.php | 17 +++++++++++++++ src/Model/LocalizedColorAwareInterface.php | 17 +++++++++++++++ src/Model/LocalizedSizeAwareInterface.php | 17 +++++++++++++++ src/Model/SizeAwareInterface.php | 4 ++++ 7 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/Model/LocalizedBrandAwareInterface.php create mode 100644 src/Model/LocalizedColorAwareInterface.php create mode 100644 src/Model/LocalizedSizeAwareInterface.php diff --git a/src/FeedContext/Google/Shopping/ProductItemContext.php b/src/FeedContext/Google/Shopping/ProductItemContext.php index 88592172..12efe872 100644 --- a/src/FeedContext/Google/Shopping/ProductItemContext.php +++ b/src/FeedContext/Google/Shopping/ProductItemContext.php @@ -17,6 +17,9 @@ use Setono\SyliusFeedPlugin\Model\ColorAwareInterface; use Setono\SyliusFeedPlugin\Model\ConditionAwareInterface; use Setono\SyliusFeedPlugin\Model\GtinAwareInterface; +use Setono\SyliusFeedPlugin\Model\LocalizedBrandAwareInterface; +use Setono\SyliusFeedPlugin\Model\LocalizedColorAwareInterface; +use Setono\SyliusFeedPlugin\Model\LocalizedSizeAwareInterface; use Setono\SyliusFeedPlugin\Model\MpnAwareInterface; use Setono\SyliusFeedPlugin\Model\SizeAwareInterface; use Setono\SyliusFeedPlugin\Model\TaxonPathAwareInterface; @@ -101,8 +104,12 @@ public function getContextList(object $product, ChannelInterface $channel, Local $data->setProductType($productType); } - if ($variant instanceof BrandAwareInterface && $variant->getBrand() !== null) { + if ($variant instanceof LocalizedBrandAwareInterface && $variant->getBrand($locale) !== null) { + $data->setBrand((string) $variant->getBrand($locale)); + } elseif ($variant instanceof BrandAwareInterface && $variant->getBrand() !== null) { $data->setBrand((string) $variant->getBrand()); + } elseif ($product instanceof LocalizedBrandAwareInterface && $product->getBrand($locale) !== null) { + $data->setBrand((string) $product->getBrand($locale)); } elseif ($product instanceof BrandAwareInterface && $product->getBrand() !== null) { $data->setBrand((string) $product->getBrand()); } @@ -119,14 +126,22 @@ public function getContextList(object $product, ChannelInterface $channel, Local $data->setMpn((string) $product->getMpn()); } - if ($variant instanceof SizeAwareInterface && $variant->getSize() !== null) { + if ($variant instanceof LocalizedSizeAwareInterface && $variant->getSize($locale) !== null) { + $data->setSize((string) $variant->getSize($locale)); + } elseif ($variant instanceof SizeAwareInterface && $variant->getSize() !== null) { $data->setSize((string) $variant->getSize()); + } elseif ($product instanceof LocalizedSizeAwareInterface && $product->getSize($locale) !== null) { + $data->setSize((string) $product->getSize($locale)); } elseif ($product instanceof SizeAwareInterface && $product->getSize() !== null) { $data->setSize((string) $product->getSize()); } - if ($variant instanceof ColorAwareInterface && $variant->getColor() !== null) { + if ($variant instanceof LocalizedColorAwareInterface && $variant->getColor($locale) !== null) { + $data->setColor((string) $variant->getColor($locale)); + } elseif ($variant instanceof ColorAwareInterface && $variant->getColor() !== null) { $data->setColor((string) $variant->getColor()); + } elseif ($product instanceof LocalizedColorAwareInterface && $product->getColor($locale) !== null) { + $data->setColor((string) $product->getColor($locale)); } elseif ($product instanceof ColorAwareInterface && $product->getColor() !== null) { $data->setColor((string) $product->getColor()); } diff --git a/src/Model/BrandAwareInterface.php b/src/Model/BrandAwareInterface.php index 1cf2ec59..e1a1c567 100644 --- a/src/Model/BrandAwareInterface.php +++ b/src/Model/BrandAwareInterface.php @@ -4,6 +4,10 @@ namespace Setono\SyliusFeedPlugin\Model; +/** + * @deprecated since 0.6.6 This interface is deprecated and will be removed in 0.7.0 + * Use \Setono\SyliusFeedPlugin\Model\LocalizedBrandAwareInterface instead. + */ interface BrandAwareInterface { /** diff --git a/src/Model/ColorAwareInterface.php b/src/Model/ColorAwareInterface.php index b34cd836..485f509e 100644 --- a/src/Model/ColorAwareInterface.php +++ b/src/Model/ColorAwareInterface.php @@ -4,6 +4,10 @@ namespace Setono\SyliusFeedPlugin\Model; +/** + * @deprecated since 0.6.6 This interface is deprecated and will be removed in 0.7.0 + * Use \Setono\SyliusFeedPlugin\Model\LocalizedColorAwareInterface instead. + */ interface ColorAwareInterface { /** diff --git a/src/Model/LocalizedBrandAwareInterface.php b/src/Model/LocalizedBrandAwareInterface.php new file mode 100644 index 00000000..1bdbb643 --- /dev/null +++ b/src/Model/LocalizedBrandAwareInterface.php @@ -0,0 +1,17 @@ + Date: Mon, 24 Jan 2022 11:40:14 +0100 Subject: [PATCH 2/4] Fix ecs --- src/Message/Handler/GenerateBatchHandler.php | 2 ++ src/Message/Handler/GenerateFeedHandler.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Message/Handler/GenerateBatchHandler.php b/src/Message/Handler/GenerateBatchHandler.php index 5a8235d0..de3aa518 100644 --- a/src/Message/Handler/GenerateBatchHandler.php +++ b/src/Message/Handler/GenerateBatchHandler.php @@ -47,7 +47,9 @@ final class GenerateBatchHandler implements MessageHandlerInterface { use GetChannelTrait; + use GetFeedTrait; + use GetLocaleTrait; private RequestContext $initialRequestContext; diff --git a/src/Message/Handler/GenerateFeedHandler.php b/src/Message/Handler/GenerateFeedHandler.php index c962acf5..d49fe54c 100644 --- a/src/Message/Handler/GenerateFeedHandler.php +++ b/src/Message/Handler/GenerateFeedHandler.php @@ -20,7 +20,9 @@ final class GenerateFeedHandler implements MessageHandlerInterface { use GetChannelTrait; + use GetFeedTrait; + use GetLocaleTrait; private FeedTypeRegistryInterface $feedTypeRegistry; From 5132fa78e41536f1922cbf3f6cc4f6975ea8ff6b Mon Sep 17 00:00:00 2001 From: Fabiana Romagnoli Date: Mon, 24 Jan 2022 12:25:22 +0100 Subject: [PATCH 3/4] Normalize composer.lock --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index a9741575..a793eb4a 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "setono/sylius-feed-plugin", - "type": "symfony-bundle", "description": "Plugin to generate feeds within the Sylius ecommerce platform", "license": "MIT", + "type": "symfony-bundle", "require": { "php": ">=7.4", "ext-json": "*", @@ -54,14 +54,7 @@ "symfony/web-profiler-bundle": "^5.0", "weirdan/doctrine-psalm-plugin": "^1.0" }, - "config": { - "sort-packages": true - }, - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, + "prefer-stable": true, "autoload": { "psr-4": { "Setono\\SyliusFeedPlugin\\": "src/" @@ -75,7 +68,14 @@ "tests/Application/Kernel.php" ] }, - "prefer-stable": true, + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "scripts": { "analyse": [ "@ensure-test-container-exists", From b2fdd452196a6327664e0a49a23574af5b8213ee Mon Sep 17 00:00:00 2001 From: Fabiana Romagnoli Date: Mon, 13 Jun 2022 14:48:17 +0200 Subject: [PATCH 4/4] Fix CS --- src/Message/Handler/GenerateBatchHandler.php | 2 -- src/Message/Handler/GenerateFeedHandler.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/Message/Handler/GenerateBatchHandler.php b/src/Message/Handler/GenerateBatchHandler.php index de3aa518..5a8235d0 100644 --- a/src/Message/Handler/GenerateBatchHandler.php +++ b/src/Message/Handler/GenerateBatchHandler.php @@ -47,9 +47,7 @@ final class GenerateBatchHandler implements MessageHandlerInterface { use GetChannelTrait; - use GetFeedTrait; - use GetLocaleTrait; private RequestContext $initialRequestContext; diff --git a/src/Message/Handler/GenerateFeedHandler.php b/src/Message/Handler/GenerateFeedHandler.php index d49fe54c..c962acf5 100644 --- a/src/Message/Handler/GenerateFeedHandler.php +++ b/src/Message/Handler/GenerateFeedHandler.php @@ -20,9 +20,7 @@ final class GenerateFeedHandler implements MessageHandlerInterface { use GetChannelTrait; - use GetFeedTrait; - use GetLocaleTrait; private FeedTypeRegistryInterface $feedTypeRegistry;