11
11
use Magento \Framework \Api \Search \AggregationInterface ;
12
12
use Magento \Framework \Api \Search \BucketInterface ;
13
13
use Magento \CatalogGraphQl \DataProvider \Product \LayeredNavigation \Formatter \LayerFormatter ;
14
+ use Magento \Catalog \Api \ProductAttributeRepositoryInterface ;
14
15
15
16
/**
16
17
* @inheritdoc
@@ -27,6 +28,11 @@ class Price implements LayerBuilderInterface
27
28
*/
28
29
private $ layerFormatter ;
29
30
31
+ /**
32
+ * @var ProductAttributeRepositoryInterface
33
+ */
34
+ private $ attributeRepository ;
35
+
30
36
/**
31
37
* @var array
32
38
*/
@@ -39,11 +45,14 @@ class Price implements LayerBuilderInterface
39
45
40
46
/**
41
47
* @param LayerFormatter $layerFormatter
48
+ * @param ProductAttributeRepositoryInterface $attributeRepository
42
49
*/
43
50
public function __construct (
44
- LayerFormatter $ layerFormatter
51
+ LayerFormatter $ layerFormatter ,
52
+ ProductAttributeRepositoryInterface $ attributeRepository
45
53
) {
46
54
$ this ->layerFormatter = $ layerFormatter ;
55
+ $ this ->attributeRepository = $ attributeRepository ;
47
56
}
48
57
49
58
/**
@@ -52,13 +61,24 @@ public function __construct(
52
61
*/
53
62
public function build (AggregationInterface $ aggregation , ?int $ storeId ): array
54
63
{
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
+
55
75
$ bucket = $ aggregation ->getBucket (self ::PRICE_BUCKET );
56
76
if ($ this ->isBucketEmpty ($ bucket )) {
57
77
return [];
58
78
}
59
79
60
80
$ result = $ this ->layerFormatter ->buildLayer (
61
- self :: $ bucketMap [ self :: PRICE_BUCKET ][ ' label ' ] ,
81
+ $ storeFrontLabel ,
62
82
\count ($ bucket ->getValues ()),
63
83
self ::$ bucketMap [self ::PRICE_BUCKET ]['request_name ' ]
64
84
);
0 commit comments