Skip to content

Commit fb12624

Browse files
committed
MC-20244: Pricing :: FPT calculation
- expose weee attributes
1 parent 21699ee commit fb12624

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/PriceRange.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Exception\LocalizedException;
1717
use Magento\Framework\Pricing\SaleableInterface;
1818
use Magento\Store\Api\Data\StoreInterface;
19+
use Magento\Framework\Pricing\Amount\AmountInterface;
1920

2021
/**
2122
* Format product's pricing information for price_range field
@@ -80,8 +81,9 @@ private function getMinimumProductPrice(SaleableInterface $product, StoreInterfa
8081
$priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId());
8182
$regularPrice = $priceProvider->getMinimalRegularPrice($product)->getValue();
8283
$finalPrice = $priceProvider->getMinimalFinalPrice($product)->getValue();
83-
84-
return $this->formatPrice($regularPrice, $finalPrice, $store);
84+
$minPriceArray = $this->formatPrice($regularPrice, $finalPrice, $store);
85+
$minPriceArray['model'] = $product;
86+
return $minPriceArray;
8587
}
8688

8789
/**
@@ -96,8 +98,9 @@ private function getMaximumProductPrice(SaleableInterface $product, StoreInterfa
9698
$priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId());
9799
$regularPrice = $priceProvider->getMaximalRegularPrice($product)->getValue();
98100
$finalPrice = $priceProvider->getMaximalFinalPrice($product)->getValue();
99-
100-
return $this->formatPrice($regularPrice, $finalPrice, $store);
101+
$maxPriceArray = $this->formatPrice($regularPrice, $finalPrice, $store);
102+
$maxPriceArray['model'] = $product;
103+
return $maxPriceArray;
101104
}
102105

103106
/**

app/code/Magento/WeeeGraphQl/Model/Resolver/FptResolver.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CatalogGraphQl\Model\Resolver;
8+
namespace Magento\WeeeGraphQl\Model\Resolver;
99

1010
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Weee\Helper\Data;
1314

1415
class FptResolver implements ResolverInterface
1516
{
17+
18+
/**
19+
* @var Data
20+
*/
21+
private $weeeHelper;
22+
23+
/**
24+
* @param Data $weeeHelper
25+
*/
26+
public function __construct(Data $weeeHelper)
27+
{
28+
$this->weeeHelper = $weeeHelper;
29+
}
30+
1631
/**
1732
* @inheritdoc
1833
*/
@@ -23,7 +38,19 @@ public function resolve(
2338
array $value = null,
2439
array $args = null
2540
) {
41+
$fptArray = [];
42+
$product = $value['model'];
43+
$attributes = $this->weeeHelper->getProductWeeeAttributesForDisplay($product);
44+
foreach ($attributes as $attribute) {
45+
$fptArray[] = [
46+
'amount' => [
47+
'value' => $attribute->getData('amount'),
48+
'currency' => $value['final_price']['currency'],
49+
],
50+
'label' => $attribute->getData('name')
51+
];
52+
}
2653

27-
return [];
54+
return $fptArray;
2855
}
2956
}

0 commit comments

Comments
 (0)