From 0d498dc285ab153e665d31c260129817a9be1fec Mon Sep 17 00:00:00 2001 From: Rihards Abolins Date: Tue, 2 Nov 2021 10:55:50 +0200 Subject: [PATCH] [2844] Downloadable link correct currency --- src/Model/Resolver/Product/Links.php | 66 ++++++++++++++++++++++++++++ src/etc/di.xml | 3 ++ 2 files changed, 69 insertions(+) create mode 100644 src/Model/Resolver/Product/Links.php diff --git a/src/Model/Resolver/Product/Links.php b/src/Model/Resolver/Product/Links.php new file mode 100644 index 0000000..00cc4ab --- /dev/null +++ b/src/Model/Resolver/Product/Links.php @@ -0,0 +1,66 @@ +pricingHelper = $pricingHelper; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + + /** @var Product $product */ + $product = $value['model']; + $data = parent::resolve($field, $context, $info, $value, $args); + + foreach ($data as &$link) { + $link['price'] = $this->pricingHelper->currencyByStore( + $link['price'], $product->getStore(), false + ); + } + + return $data; + } +} diff --git a/src/etc/di.xml b/src/etc/di.xml index 0330657..167217f 100755 --- a/src/etc/di.xml +++ b/src/etc/di.xml @@ -98,6 +98,9 @@ + +