Skip to content

Commit 3a95f15

Browse files
committed
MC-37726: Price filter uses base currency for ranges
1 parent cb8ae36 commit 3a95f15

File tree

2 files changed

+60
-31
lines changed

2 files changed

+60
-31
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,54 @@ public function testProductWithSinglePrice()
7878
$this->assertPrices($expectedPriceRange, $product['price_range']);
7979
}
8080

81+
/**
82+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
83+
* @magentoConfigFixture default_store currency/options/allow EUR,USD
84+
*/
85+
public function testProductWithSinglePriceNonDefaultCurrency()
86+
{
87+
$skus = ['simple'];
88+
$query = $this->getProductQuery($skus);
89+
$headerMap = [
90+
'Content-Currency' => 'EUR'
91+
];
92+
$result = $this->graphQlQuery($query, [], '', $headerMap);
93+
94+
$this->assertArrayNotHasKey('errors', $result);
95+
$this->assertNotEmpty($result['products']['items']);
96+
$product = $result['products']['items'][0];
97+
$this->assertNotEmpty($product['price_range']);
98+
99+
$expectedPriceRange = [
100+
"minimum_price" => [
101+
"regular_price" => [
102+
"value" => 20
103+
],
104+
"final_price" => [
105+
"value" => 20
106+
],
107+
"discount" => [
108+
"amount_off" => 0,
109+
"percent_off" => 0
110+
]
111+
],
112+
"maximum_price" => [
113+
"regular_price" => [
114+
"value" => 20
115+
],
116+
"final_price" => [
117+
"value" => 20
118+
],
119+
"discount" => [
120+
"amount_off" => 0,
121+
"percent_off" => 0
122+
]
123+
]
124+
];
125+
126+
$this->assertPrices($expectedPriceRange, $product['price_range'], 'EUR');
127+
}
128+
81129
/**
82130
* Pricing for Simple, Grouped and Configurable products with no special or tier prices configured
83131
*
@@ -909,7 +957,7 @@ private function getQueryConfigurableProductAndVariants(array $sku): string
909957
name
910958
sku
911959
price_range {
912-
minimum_price {regular_price
960+
minimum_price {regular_price
913961
{
914962
value
915963
currency
@@ -949,13 +997,13 @@ private function getQueryConfigurableProductAndVariants(array $sku): string
949997
... on ConfigurableProduct{
950998
variants{
951999
product{
952-
1000+
9531001
sku
9541002
price_range {
9551003
minimum_price {regular_price {value}
9561004
final_price {
9571005
value
958-
1006+
9591007
}
9601008
discount {
9611009
amount_off
@@ -965,11 +1013,11 @@ private function getQueryConfigurableProductAndVariants(array $sku): string
9651013
maximum_price {
9661014
regular_price {
9671015
value
968-
1016+
9691017
}
9701018
final_price {
9711019
value
972-
1020+
9731021
}
9741022
discount {
9751023
amount_off
@@ -985,7 +1033,7 @@ private function getQueryConfigurableProductAndVariants(array $sku): string
9851033
final_price{value}
9861034
quantity
9871035
}
988-
1036+
9891037
}
9901038
}
9911039
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,12 @@ function ($a) {
8989
}
9090

9191
/**
92-
* @magentoApiDataFixture Magento/Store/_files/second_store_with_second_currency.php
9392
* @magentoApiDataFixture Magento/Catalog/_files/products_for_search.php
93+
* @magentoConfigFixture default_store currency/options/allow EUR,USD
9494
*/
9595
public function testAggregationPriceRangesWithCurrencyHeader()
9696
{
97-
// add USD as allowed (not default) currency
98-
$objectManager = Bootstrap::getObjectManager();
99-
/* @var Store $store */
100-
$store = $objectManager->create(Store::class);
101-
$store->load('fixture_second_store');
102-
/** @var Config $configResource */
103-
$configResource = $objectManager->get(Config::class);
104-
$configResource->saveConfig(
105-
Currency::XML_PATH_CURRENCY_ALLOW,
106-
'USD',
107-
ScopeInterface::SCOPE_STORES,
108-
$store->getId()
109-
);
110-
// Configuration cache clean is required to reload currency setting
111-
/** @var System $config */
112-
$config = $objectManager->get(System::class);
113-
$config->clean();
114-
115-
$headerMap['Store'] = 'fixture_second_store';
116-
$headerMap['Content-Currency'] = 'USD';
97+
$headerMap['Content-Currency'] = 'EUR';
11798
$query = $this->getGraphQlQuery(
11899
'"search_product_1", "search_product_2", "search_product_3", "search_product_4" ,"search_product_5"'
119100
);
@@ -131,10 +112,10 @@ function ($a) {
131112
$this->assertEquals('Price', $priceAggregation['label']);
132113
$this->assertEquals(4, $priceAggregation['count']);
133114
$expectedOptions = [
134-
['label' => '10-20', 'value'=> '10_20', 'count' => '2'],
135-
['label' => '20-30', 'value'=> '20_30', 'count' => '1'],
136-
['label' => '30-40', 'value'=> '30_40', 'count' => '1'],
137-
['label' => '40-50', 'value'=> '40_50', 'count' => '1']
115+
['label' => '20-40', 'value'=> '20_40', 'count' => '2'],
116+
['label' => '40-60', 'value'=> '40_60', 'count' => '1'],
117+
['label' => '60-80', 'value'=> '60_80', 'count' => '1'],
118+
['label' => '80-100', 'value'=> '80_100', 'count' => '1']
138119
];
139120
$this->assertEquals($expectedOptions, $priceAggregation['options']);
140121
}

0 commit comments

Comments
 (0)