77
88namespace Magento \CatalogGraphQl \Model \Resolver ;
99
10+ use Magento \CatalogGraphQl \DataProvider \Product \LayeredNavigation \LayerBuilder ;
11+ use Magento \Directory \Model \PriceCurrency ;
12+ use Magento \Framework \App \ObjectManager ;
1013use Magento \Framework \GraphQl \Config \Element \Field ;
1114use Magento \Framework \GraphQl \Query \ResolverInterface ;
1215use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
13- use Magento \CatalogGraphQl \DataProvider \Product \LayeredNavigation \LayerBuilder ;
1416use Magento \Store \Api \Data \StoreInterface ;
1517
1618/**
@@ -28,16 +30,24 @@ class Aggregations implements ResolverInterface
2830 */
2931 private $ layerBuilder ;
3032
33+ /**
34+ * @var PriceCurrency
35+ */
36+ private $ priceCurrency ;
37+
3138 /**
3239 * @param \Magento\CatalogGraphQl\Model\Resolver\Layer\DataProvider\Filters $filtersDataProvider
40+ * @param PriceCurrency $priceCurrency
3341 * @param LayerBuilder $layerBuilder
3442 */
3543 public function __construct (
3644 \Magento \CatalogGraphQl \Model \Resolver \Layer \DataProvider \Filters $ filtersDataProvider ,
37- LayerBuilder $ layerBuilder
45+ LayerBuilder $ layerBuilder ,
46+ PriceCurrency $ priceCurrency = null
3847 ) {
3948 $ this ->filtersDataProvider = $ filtersDataProvider ;
4049 $ this ->layerBuilder = $ layerBuilder ;
50+ $ this ->priceCurrency = $ priceCurrency ?: ObjectManager::getInstance ()->get (PriceCurrency::class);
4151 }
4252
4353 /**
@@ -60,7 +70,16 @@ public function resolve(
6070 /** @var StoreInterface $store */
6171 $ store = $ context ->getExtensionAttributes ()->getStore ();
6272 $ storeId = (int )$ store ->getId ();
63- return $ this ->layerBuilder ->build ($ aggregations , $ storeId );
73+ $ results = $ this ->layerBuilder ->build ($ aggregations , $ storeId );
74+ if (isset ($ results ['price_bucket ' ])) {
75+ foreach ($ results ['price_bucket ' ]['options ' ] as &$ value ) {
76+ list ($ from , $ to ) = explode ('- ' , $ value ['label ' ]);
77+ $ newLabel = $ this ->priceCurrency ->convertAndRound ($ from ) . '- ' . $ this ->priceCurrency ->convertAndRound ($ to );
78+ $ value ['label ' ] = $ newLabel ;
79+ $ value ['value ' ] = str_replace ('- ' , '_ ' , $ newLabel );
80+ }
81+ }
82+ return $ results ;
6483 } else {
6584 return [];
6685 }
0 commit comments