diff --git a/Formatter/AppliedPromotionInformationFormatter.php b/Formatter/AppliedPromotionInformationFormatter.php index a6234c674..b5c68ca3d 100644 --- a/Formatter/AppliedPromotionInformationFormatter.php +++ b/Formatter/AppliedPromotionInformationFormatter.php @@ -20,13 +20,16 @@ final class AppliedPromotionInformationFormatter implements AppliedPromotionInfo { public function format(CatalogPromotionInterface $catalogPromotion): array { + $translationLabels = []; + /** @var CatalogPromotionTranslationInterface $translation */ - $translation = $catalogPromotion->getTranslations()->first(); + foreach ($catalogPromotion->getTranslations() as $translation) { + $translationLabels[$translation->getLocale()] = ['name' => $translation->getLabel()]; + } + /** @var string $code */ $code = $catalogPromotion->getCode(); - /** @var string $name */ - $name = $translation->getLabel(); - return [$code => ['name' => $name]]; + return [$code => $translationLabels]; } } diff --git a/Formatter/AppliedPromotionInformationFormatterInterface.php b/Formatter/AppliedPromotionInformationFormatterInterface.php index b2d3bca90..e638d3351 100644 --- a/Formatter/AppliedPromotionInformationFormatterInterface.php +++ b/Formatter/AppliedPromotionInformationFormatterInterface.php @@ -6,8 +6,7 @@ use Sylius\Component\Core\Model\CatalogPromotionInterface; -interface -AppliedPromotionInformationFormatterInterface +interface AppliedPromotionInformationFormatterInterface { public function format(CatalogPromotionInterface $catalogPromotion): array; } diff --git a/Processor/CatalogPromotionProcessor.php b/Processor/CatalogPromotionProcessor.php index 731549bf9..c4472fdb3 100644 --- a/Processor/CatalogPromotionProcessor.php +++ b/Processor/CatalogPromotionProcessor.php @@ -18,7 +18,6 @@ use Sylius\Component\Core\Model\CatalogPromotionInterface; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Provider\CatalogPromotionVariantsProviderInterface; -use Sylius\Component\Promotion\Model\CatalogPromotionActionInterface; final class CatalogPromotionProcessor implements CatalogPromotionProcessorInterface { diff --git a/spec/Formatter/AppliedPromotionInformationFormatterSpec.php b/spec/Formatter/AppliedPromotionInformationFormatterSpec.php index 95d8e8ce9..1614670b1 100644 --- a/spec/Formatter/AppliedPromotionInformationFormatterSpec.php +++ b/spec/Formatter/AppliedPromotionInformationFormatterSpec.php @@ -32,9 +32,10 @@ function it_formats_applied_promotion_information( ): void { $catalogPromotion->getTranslations()->willReturn(new ArrayCollection([$translation->getWrappedObject()])); - $catalogPromotion->getCode()->willReturn('winter_sale'); $translation->getLabel()->willReturn('Winter sale'); + $translation->getLocale()->willReturn('en_US'); + $catalogPromotion->getCode()->willReturn('winter_sale'); - $this->format($catalogPromotion)->shouldReturn(['winter_sale' => ['name' => 'Winter sale']]); + $this->format($catalogPromotion)->shouldReturn(['winter_sale' => ['en_US' => ['name' => 'Winter sale']]]); } }