Skip to content

Commit 27c344d

Browse files
author
Gabriel Galvao da Gama
committed
Merge branch '2.4.2-develop' of github.com:magento/magento2ce into #30980-2
2 parents f9d15e9 + 5cc7163 commit 27c344d

File tree

11 files changed

+206
-27
lines changed

11 files changed

+206
-27
lines changed

app/code/Magento/AsynchronousOperations/etc/db_schema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<index referenceId="MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID" indexType="btree">
3131
<column name="user_id"/>
3232
</index>
33+
<index referenceId="MAGENTO_BULK_START_TIME" indexType="btree">
34+
<column name="start_time"/>
35+
</index>
3336
</table>
3437
<table name="magento_operation" resource="default" engine="innodb" comment="Operation entity">
3538
<column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true"

app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"index": {
1313
"MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID": true,
14-
"MAGENTO_BULK_USER_ID": true
14+
"MAGENTO_BULK_USER_ID": true,
15+
"MAGENTO_BULK_START_TIME": true
1516
},
1617
"constraint": {
1718
"PRIMARY": true,

app/code/Magento/Paypal/Controller/Express/GetTokenData.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ public function execute(): ResultInterface
168168
return $controllerResult->setData($responseContent);
169169
}
170170

171+
/**
172+
* Prepare quote specified for checkout.
173+
*
174+
* @return \Magento\Quote\Api\Data\CartInterface
175+
* @throws LocalizedException
176+
*/
177+
private function prepareQuote()
178+
{
179+
$quoteId = $this->getRequest()->getParam('quote_id');
180+
if ($quoteId) {
181+
$quote = $this->userContext->getUserId()
182+
? $this->cartRepository->get($quoteId)
183+
: $this->guestCartRepository->get($quoteId);
184+
if ((int)$quote->getCustomer()->getId() === (int)$this->userContext->getUserId()) {
185+
return $quote;
186+
}
187+
}
188+
return $this->_getQuote();
189+
}
171190
/**
172191
* Get paypal token
173192
*
@@ -176,7 +195,7 @@ public function execute(): ResultInterface
176195
*/
177196
private function getToken(): ?string
178197
{
179-
$quote = $this->_getQuote();
198+
$quote = $this->prepareQuote();
180199
$this->_initCheckout($quote);
181200

182201
if ($quote->getIsMultiShipping()) {

app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,64 @@ public function getStoreByWebsiteId($websiteId)
5050
* @param int $websiteId
5151
* @param bool $available
5252
* @param int|null $storeGroupId
53+
* @param int|null $storeId
5354
* @return array
5455
*/
55-
public function getWebsiteStores(int $websiteId, bool $available = false, int $storeGroupId = null): array
56-
{
56+
public function getWebsiteStores(
57+
int $websiteId,
58+
bool $available = false,
59+
int $storeGroupId = null,
60+
int $storeId = null
61+
): array {
5762
$connection = $this->resource->getConnection();
5863
$storeTable = $this->resource->getTableName('store');
59-
$storeSelect = $connection->select()->from($storeTable)->where(
60-
'website_id = ?',
61-
$websiteId
62-
);
64+
$storeSelect = $connection->select()
65+
->from(['main_table' => $storeTable])
66+
->join(
67+
['group_table' => $this->resource->getTableName('store_group')],
68+
'main_table.group_id = group_table.group_id',
69+
[
70+
'store_group_code' => 'code',
71+
'store_group_name' => 'name',
72+
'default_store_id'
73+
]
74+
)
75+
->join(
76+
['website' => $this->resource->getTableName('store_website')],
77+
'main_table.website_id = website.website_id',
78+
[
79+
'website_code' => 'code',
80+
'website_name' => 'name',
81+
'website_sort_order' => 'sort_order',
82+
'default_group_id'
83+
]
84+
);
6385

6486
if ($storeGroupId) {
6587
$storeSelect = $storeSelect->where(
66-
'group_id = ?',
88+
'main_table.group_id = ?',
6789
$storeGroupId
6890
);
6991
}
7092

93+
if ($storeId) {
94+
$storeSelect = $storeSelect->where(
95+
'main_table.store_id = ?',
96+
$storeId
97+
);
98+
}
99+
71100
if ($available) {
72101
$storeSelect = $storeSelect->where(
73-
'is_active = 1'
102+
'main_table.is_active = 1'
74103
);
75104
}
76105

106+
$storeSelect = $storeSelect->where(
107+
'main_table.website_id = ?',
108+
$websiteId
109+
);
110+
77111
return $connection->fetchAll($storeSelect);
78112
}
79113
}

app/code/Magento/StoreGraphQl/Controller/HttpRequestValidator/StoreValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function validate(HttpRequestInterface $request): void
4545
$storeCode = trim($headerValue);
4646
if (!$this->isStoreActive($storeCode)) {
4747
$this->storeManager->setCurrentStore(null);
48-
throw new GraphQlInputException(__('Requested store is not found ({$storeCode})'));
48+
throw new GraphQlInputException(__('Requested store is not found (%1)', [$storeCode]));
4949
}
5050
}
5151
}

app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,19 @@ public function __construct(
6565
*/
6666
public function getStoreConfigData(StoreInterface $store): array
6767
{
68-
$defaultStoreConfig = $this->storeConfigManager->getStoreConfigs([$store->getCode()]);
69-
return $this->prepareStoreConfigData(current($defaultStoreConfig), $store->getName());
68+
$defaultWebsiteStore = $this->storeWebsiteRelation->getWebsiteStores(
69+
(int) $store->getWebsiteId(),
70+
true,
71+
(int) $store->getStoreGroupId(),
72+
(int) $store->getStoreId()
73+
);
74+
if (empty($defaultWebsiteStore)) {
75+
return [];
76+
}
77+
78+
$storeConfigs = $this->storeConfigManager->getStoreConfigs([$store->getCode()]);
79+
80+
return $this->prepareStoreConfigData(current($storeConfigs), current($defaultWebsiteStore));
7081
}
7182

7283
/**
@@ -86,7 +97,7 @@ public function getAvailableStoreConfig(int $websiteId, int $storeGroupId = null
8697

8798
foreach ($storeConfigs as $storeConfig) {
8899
$key = array_search($storeConfig->getCode(), array_column($websiteStores, 'code'), true);
89-
$storesConfigData[] = $this->prepareStoreConfigData($storeConfig, $websiteStores[$key]['name']);
100+
$storesConfigData[] = $this->prepareStoreConfigData($storeConfig, $websiteStores[$key]);
90101
}
91102

92103
return $storesConfigData;
@@ -96,15 +107,25 @@ public function getAvailableStoreConfig(int $websiteId, int $storeGroupId = null
96107
* Prepare store config data
97108
*
98109
* @param StoreConfigInterface $storeConfig
99-
* @param string $storeName
110+
* @param array $storeData
100111
* @return array
101112
*/
102-
private function prepareStoreConfigData(StoreConfigInterface $storeConfig, string $storeName): array
113+
private function prepareStoreConfigData(StoreConfigInterface $storeConfig, array $storeData): array
103114
{
104115
return array_merge([
105116
'id' => $storeConfig->getId(),
106117
'code' => $storeConfig->getCode(),
118+
'store_code' => $storeConfig->getCode(),
119+
'store_name' => $storeData['name'] ?? null,
120+
'store_sort_order' => $storeData['sort_order'] ?? null,
121+
'is_default_store' => $storeData['default_store_id'] == $storeConfig->getId() ?? null,
122+
'store_group_code' => $storeData['store_group_code'] ?? null,
123+
'store_group_name' => $storeData['store_group_name'] ?? null,
124+
'is_default_store_group' => $storeData['default_group_id'] == $storeData['group_id'] ?? null,
125+
'store_group_default_store_code' => $storeData['store_group_default_store_code'] ?? null,
107126
'website_id' => $storeConfig->getWebsiteId(),
127+
'website_code' => $storeData['website_code'] ?? null,
128+
'website_name' => $storeData['website_name'] ?? null,
108129
'locale' => $storeConfig->getLocale(),
109130
'base_currency_code' => $storeConfig->getBaseCurrencyCode(),
110131
'default_display_currency_code' => $storeConfig->getDefaultDisplayCurrencyCode(),
@@ -118,7 +139,6 @@ private function prepareStoreConfigData(StoreConfigInterface $storeConfig, strin
118139
'secure_base_link_url' => $storeConfig->getSecureBaseLinkUrl(),
119140
'secure_base_static_url' => $storeConfig->getSecureBaseStaticUrl(),
120141
'secure_base_media_url' => $storeConfig->getSecureBaseMediaUrl(),
121-
'store_name' => $storeName,
122142
], $this->getExtendedConfigData((int)$storeConfig->getId()));
123143
}
124144

app/code/Magento/StoreGraphQl/Test/Unit/StoreValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testValidate(array $config): void
9595
->method('setCurrentStore')
9696
->with(null)
9797
->willReturnSelf();
98-
$this->expectExceptionMessage('Requested store is not found ({$storeCode})');
98+
$this->expectExceptionMessage('Requested store is not found (sv1)');
9999
$this->storeValidator->validate($this->requestMock);
100100
}
101101

app/code/Magento/StoreGraphQl/etc/schema.graphqls

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ type Website @doc(description: "Website is deprecated because it is should not b
1717
}
1818

1919
type StoreConfig @doc(description: "The type contains information about a store config") {
20-
id : Int @doc(description: "The ID number assigned to the store")
21-
code : String @doc(description: "A code assigned to the store to identify it")
22-
website_id : Int @doc(description: "The ID number assigned to the website store belongs")
20+
id : Int @deprecated(reason: "Use `store_code` instead.") @doc(description: "The ID number assigned to the store")
21+
code : String @deprecated(reason: "Use `store_code` instead.") @doc(description: "A code assigned to the store to identify it")
22+
store_code: ID @doc(description: "The unique ID of the store view. In the Admin, this is called the Store View Code. When making a GraphQL call, assign this value to the `Store` header to provide the scope")
23+
store_name : String @doc(description: "The label assigned to the store view")
24+
store_sort_order : Int @doc(description: "The store view sort order")
25+
is_default_store : Boolean @doc(description: "Indicates whether the store view has been designated as the default within the store group")
26+
store_group_code : ID @doc(description: "The unique ID assigned to the store group. In the Admin, this is called the Store Name")
27+
store_group_name : String @doc(description: "The label assigned to the store group")
28+
is_default_store_group : Boolean @doc(description: "Indicates whether the store group has been designated as the default within the website")
29+
website_id : Int @deprecated(reason: "The field should not be used on the storefront") @doc(description: "The ID number assigned to the website store")
30+
website_code : ID @doc(description: "The unique ID for the website")
31+
website_name : ID @doc(description: "The label assigned to the website")
2332
locale : String @doc(description: "Store locale")
2433
base_currency_code : String @doc(description: "Base currency code")
2534
default_display_currency_code : String @doc(description: "Default display currency code")
@@ -33,6 +42,5 @@ type StoreConfig @doc(description: "The type contains information about a store
3342
secure_base_link_url : String @doc(description: "Secure base link URL for the store")
3443
secure_base_static_url : String @doc(description: "Secure base static URL for the store")
3544
secure_base_media_url : String @doc(description: "Secure base media URL for the store")
36-
store_name : String @doc(description: "Name of the store")
3745
use_store_in_url: Boolean @doc(description: "The configuration determines if the store code should be used in the URL")
3846
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Store/AvailableStoreConfigTest.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,16 @@ public function testDefaultWebsiteAvailableStoreConfigs(): void
7272
availableStores {
7373
id,
7474
code,
75+
store_code,
76+
store_name,
77+
store_sort_order,
78+
is_default_store,
79+
store_group_code,
80+
store_group_name,
81+
is_default_store_group,
7582
website_id,
83+
website_code,
84+
website_name,
7685
locale,
7786
base_currency_code,
7887
default_display_currency_code,
@@ -112,7 +121,16 @@ public function testNonDefaultWebsiteAvailableStoreConfigs(): void
112121
availableStores {
113122
id,
114123
code,
124+
store_code,
125+
store_name,
126+
store_sort_order,
127+
is_default_store,
128+
store_group_code,
129+
store_group_name,
130+
is_default_store_group,
115131
website_id,
132+
website_code,
133+
website_name,
116134
locale,
117135
base_currency_code,
118136
default_display_currency_code,
@@ -148,10 +166,26 @@ public function testNonDefaultWebsiteAvailableStoreConfigs(): void
148166
*/
149167
private function validateStoreConfig(StoreConfigInterface $storeConfig, array $responseConfig): void
150168
{
169+
/** @var Store $store */
151170
$store = $this->objectManager->get(Store::class);
152171
$this->storeResource->load($store, $storeConfig->getCode(), 'code');
153172
$this->assertEquals($storeConfig->getId(), $responseConfig['id']);
154173
$this->assertEquals($storeConfig->getCode(), $responseConfig['code']);
174+
$this->assertEquals($store->getName(), $responseConfig['store_name']);
175+
$this->assertEquals($store->getSortOrder(), $responseConfig['store_sort_order']);
176+
$this->assertEquals(
177+
$store->getGroup()->getDefaultStoreId() == $store->getId(),
178+
$responseConfig['is_default_store']
179+
);
180+
$this->assertEquals($store->getGroup()->getCode(), $responseConfig['store_group_code']);
181+
$this->assertEquals($store->getGroup()->getName(), $responseConfig['store_group_name']);
182+
$this->assertEquals(
183+
$store->getWebsite()->getDefaultGroupId() === $store->getGroupId(),
184+
$responseConfig['is_default_store_group']
185+
);
186+
$this->assertEquals($store->getWebsite()->getCode(), $responseConfig['website_code']);
187+
$this->assertEquals($store->getWebsite()->getName(), $responseConfig['website_name']);
188+
$this->assertEquals($storeConfig->getCode(), $responseConfig['store_code']);
155189
$this->assertEquals($storeConfig->getLocale(), $responseConfig['locale']);
156190
$this->assertEquals($storeConfig->getBaseCurrencyCode(), $responseConfig['base_currency_code']);
157191
$this->assertEquals(
@@ -168,7 +202,6 @@ private function validateStoreConfig(StoreConfigInterface $storeConfig, array $r
168202
$this->assertEquals($storeConfig->getSecureBaseLinkUrl(), $responseConfig['secure_base_link_url']);
169203
$this->assertEquals($storeConfig->getSecureBaseStaticUrl(), $responseConfig['secure_base_static_url']);
170204
$this->assertEquals($storeConfig->getSecureBaseMediaUrl(), $responseConfig['secure_base_media_url']);
171-
$this->assertEquals($store->getName(), $responseConfig['store_name']);
172205
$this->assertEquals($store->isUseStoreInUrl(), $responseConfig['use_store_in_url']);
173206
}
174207

@@ -193,7 +226,16 @@ public function testAllStoreConfigsWithCodeInUrlEnabled(): void
193226
availableStores(useCurrentGroup:false) {
194227
id,
195228
code,
229+
store_code,
230+
store_name,
231+
store_sort_order,
232+
is_default_store,
233+
store_group_code,
234+
store_group_name,
235+
is_default_store_group,
196236
website_id,
237+
website_code,
238+
website_name,
197239
locale,
198240
base_currency_code,
199241
default_display_currency_code,
@@ -236,7 +278,16 @@ public function testCurrentGroupStoreConfigs(): void
236278
availableStores(useCurrentGroup:true) {
237279
id,
238280
code,
281+
store_code,
282+
store_name,
283+
store_sort_order,
284+
is_default_store,
285+
store_group_code,
286+
store_group_name,
287+
is_default_store_group,
239288
website_id,
289+
website_code,
290+
website_name,,
240291
locale,
241292
base_currency_code,
242293
default_display_currency_code,

0 commit comments

Comments
 (0)