Skip to content

Commit 6d0225b

Browse files
committed
MC-18403: Pricing :: Product pricing schema
- fix bundle product fixed pricing
1 parent 143179b commit 6d0225b

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

app/code/Magento/BundleGraphQl/etc/graphql/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,14 @@
4040
</argument>
4141
</arguments>
4242
</type>
43+
44+
<type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\AttributeProcessor">
45+
<arguments>
46+
<argument name="fieldToAttributeMap" xsi:type="array">
47+
<item name="price_range" xsi:type="array">
48+
<item name="price_type" xsi:type="string">price_type</item>
49+
</item>
50+
</argument>
51+
</arguments>
52+
</type>
4353
</config>

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/AttributeProcessor.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class AttributeProcessor implements CollectionProcessorInterface
2323
*
2424
* @var array
2525
*/
26-
private $fieldToAttributeMap = [
27-
'price_range' => 'price'
28-
];
26+
private $fieldToAttributeMap = [];
2927

3028
/**
3129
* @param array $fieldToAttributeMap
@@ -44,13 +42,32 @@ public function process(
4442
array $attributeNames
4543
): Collection {
4644
foreach ($attributeNames as $name) {
47-
$attributeName = $name;
48-
if (isset($this->fieldToAttributeMap[$name])) {
49-
$attributeName = $this->fieldToAttributeMap[$name];
50-
}
51-
$collection->addAttributeToSelect($attributeName);
45+
$this->addAttribute($collection, $name);
5246
}
5347

5448
return $collection;
5549
}
50+
51+
/**
52+
* Add attribute to collection select
53+
*
54+
* @param Collection $collection
55+
* @param string $attribute
56+
*/
57+
private function addAttribute(Collection $collection, string $attribute): void
58+
{
59+
if (isset($this->fieldToAttributeMap[$attribute])) {
60+
$attributeMap = $this->fieldToAttributeMap[$attribute];
61+
if (is_array($attributeMap)) {
62+
foreach ($attributeMap as $attributeName) {
63+
$collection->addAttributeToSelect($attributeName);
64+
}
65+
} else {
66+
$collection->addAttributeToSelect($attributeMap);
67+
}
68+
69+
} else {
70+
$collection->addAttributeToSelect($attribute);
71+
}
72+
}
5673
}

app/code/Magento/CatalogGraphQl/etc/graphql/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,14 @@
118118
</argument>
119119
</arguments>
120120
</type>
121+
122+
<type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\AttributeProcessor">
123+
<arguments>
124+
<argument name="fieldToAttributeMap" xsi:type="array">
125+
<item name="price_range" xsi:type="array">
126+
<item name="price" xsi:type="string">price</item>
127+
</item>
128+
</argument>
129+
</arguments>
130+
</type>
121131
</config>

0 commit comments

Comments
 (0)