Skip to content

Commit d99bf63

Browse files
committed
ACP2E-1238: attributes from GraphQL not translated
- Fixed the solution.
1 parent 49bd706 commit d99bf63

File tree

1 file changed

+22
-2
lines changed
  • app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder

1 file changed

+22
-2
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Price.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Api\Search\AggregationInterface;
1212
use Magento\Framework\Api\Search\BucketInterface;
1313
use 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

Comments
 (0)