1111use Magento \Framework \Api \Search \AggregationInterface ;
1212use Magento \Framework \Api \Search \BucketInterface ;
1313use Magento \CatalogGraphQl \DataProvider \Product \LayeredNavigation \Formatter \LayerFormatter ;
14+ use Magento \Catalog \Api \ProductAttributeRepositoryInterface ;
1415
1516/**
1617 * @inheritdoc
@@ -27,6 +28,11 @@ class Price implements LayerBuilderInterface
2728 */
2829 private $ layerFormatter ;
2930
31+ /**
32+ * @var ProductAttributeRepositoryInterface
33+ */
34+ private $ attributeRepository ;
35+
3036 /**
3137 * @var array
3238 */
@@ -39,11 +45,14 @@ class Price implements LayerBuilderInterface
3945
4046 /**
4147 * @param LayerFormatter $layerFormatter
48+ * @param ProductAttributeRepositoryInterface $attributeRepository
4249 */
4350 public function __construct (
44- LayerFormatter $ layerFormatter
51+ LayerFormatter $ layerFormatter ,
52+ ProductAttributeRepositoryInterface $ attributeRepository
4553 ) {
4654 $ this ->layerFormatter = $ layerFormatter ;
55+ $ this ->attributeRepository = $ attributeRepository ;
4756 }
4857
4958 /**
@@ -52,13 +61,24 @@ public function __construct(
5261 */
5362 public function build (AggregationInterface $ aggregation , ?int $ storeId ): array
5463 {
64+ $ storeFrontLabel = '' ;
65+
66+ $ attribute = $ this ->attributeRepository ->get (
67+ self ::$ bucketMap [self ::PRICE_BUCKET ]['request_name ' ]
68+ );
69+
70+ if ($ attribute ) {
71+ $ storeFrontLabel = isset ($ attribute ->getStorelabels ()[$ storeId ]) ?
72+ $ attribute ->getStorelabels ()[$ storeId ] : $ attribute ->getFrontendLabel ();
73+ }
74+
5575 $ bucket = $ aggregation ->getBucket (self ::PRICE_BUCKET );
5676 if ($ this ->isBucketEmpty ($ bucket )) {
5777 return [];
5878 }
5979
6080 $ result = $ this ->layerFormatter ->buildLayer (
61- self :: $ bucketMap [ self :: PRICE_BUCKET ][ ' label ' ] ,
81+ $ storeFrontLabel ,
6282 \count ($ bucket ->getValues ()),
6383 self ::$ bucketMap [self ::PRICE_BUCKET ]['request_name ' ]
6484 );
0 commit comments