Skip to content

Commit 4444b72

Browse files
author
Oleksandr Iegorov
committed
MC-43176: GraphQL returns the price ranges of a simple product on another store
1 parent b6790c2 commit 4444b72

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogGraphQl/PriceRangeTest.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ protected function setUp(): void
3434
$this->getCustomerAuthenticationHeader = $this->objectManager->get(GetCustomerAuthenticationHeader::class);
3535
}
3636

37+
/**
38+
* @magentoApiDataFixture Magento/Store/_files/second_website_with_two_stores.php
39+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_in_multiple_websites.php
40+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_in_multiple_websites_with_special_price.php
41+
*/
42+
public function testMinimalPriceForConfigurableProductWithSpecialPrice() : void
43+
{
44+
$headerMapFirstStore['Store'] = 'default';
45+
$headerMapSecondStore['Store'] = 'fixture_second_store';
46+
$query = $this->getProductsBySkuQuery();
47+
$responseForFirstWebsite = $this->graphQlQuery($query, [], '', $headerMapFirstStore);
48+
$responseForSecondWebsite = $this->graphQlQuery($query, [], '', $headerMapSecondStore);
49+
50+
$this->assertNotEmpty($responseForFirstWebsite['products']);
51+
$priceRange = $responseForFirstWebsite['products']['items'][0]['price_range'];
52+
$this->assertEquals(10, $priceRange['minimum_price']['regular_price']['value']);
53+
$this->assertEquals(10, $priceRange['minimum_price']['final_price']['value']);
54+
$this->assertEquals(10, $priceRange['maximum_price']['regular_price']['value']);
55+
$this->assertEquals(10, $priceRange['maximum_price']['final_price']['value']);
56+
57+
$this->assertNotEmpty($responseForSecondWebsite['products']);
58+
$priceRange = $responseForSecondWebsite['products']['items'][0]['price_range'];
59+
$this->assertEquals(20, $priceRange['minimum_price']['regular_price']['value']);
60+
$this->assertEquals(4, $priceRange['minimum_price']['final_price']['value']);
61+
$this->assertEquals(20, $priceRange['maximum_price']['regular_price']['value']);
62+
$this->assertEquals(4, $priceRange['maximum_price']['final_price']['value']);
63+
}
64+
3765
/**
3866
* Test for checking if catalog rule price has been applied for all customer group
3967
*
@@ -281,26 +309,6 @@ private function getProductSearchQuery(string $productSku): string
281309
QUERY;
282310
}
283311

284-
/**
285-
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_in_multiple_websites_with_special_price.php
286-
*/
287-
public function testMinimalPriceForConfigurableProductWithSpecialPrice() : void
288-
{
289-
$query = $this->getProductsBySkuQuery();
290-
$response = $this->graphQlQuery(
291-
$query,
292-
[],
293-
'',
294-
$this->getCustomerAuthenticationHeader->execute('customer@example.com', 'password')
295-
);
296-
$this->assertNotEmpty($response['products']);
297-
$priceRange = $response['products']['items'][0]['price_range'];
298-
$this->assertEquals(10, $priceRange['minimum_price']['regular_price']['value']);
299-
$this->assertEquals(10, $priceRange['minimum_price']['final_price']['value']);
300-
$this->assertEquals(10, $priceRange['maximum_price']['regular_price']['value']);
301-
$this->assertEquals(10, $priceRange['maximum_price']['final_price']['value']);
302-
}
303-
304312
/**
305313
* Get a query which user filter for product sku and returns price_range
306314
*

dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_in_multiple_websites_with_special_price.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77
use Magento\Catalog\Api\ProductRepositoryInterface;
88
use Magento\Store\Api\WebsiteRepositoryInterface;
99
use Magento\TestFramework\Helper\Bootstrap;
10-
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
1110

1211
Bootstrap::getInstance()->reinitialize();
1312

14-
Resolver::getInstance()->requireDataFixture(
15-
'Magento/ConfigurableProduct/_files/product_configurable_in_multiple_websites.php'
16-
);
17-
1813
/** @var WebsiteRepositoryInterface $repository */
1914
$repository = Bootstrap::getObjectManager()->get(WebsiteRepositoryInterface::class);
2015
$websiteId = $repository->get('test')->getId();
@@ -24,10 +19,14 @@
2419
->create(ProductRepositoryInterface::class);
2520

2621
$product = $productRepository->get('simple_20', true);
27-
$product->setWebsiteIds([$websiteId]);
2822
$product->setSpecialPrice('4');
23+
$product->setWebsiteIds([$websiteId]);
2924
$productRepository->save($product);
3025

3126
$product = $productRepository->get('simple_10', true);
3227
$product->setWebsiteIds([1]);
3328
$productRepository->save($product);
29+
30+
$product = $productRepository->get('configurable', true);
31+
$product->setWebsiteIds([1, $websiteId]);
32+
$productRepository->save($product);

0 commit comments

Comments
 (0)