Skip to content

Commit 84c01e2

Browse files
committed
ACP2E-778: REST API: Product names in cart always use default store view values
1 parent e1e90df commit 84c01e2

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

app/code/Magento/Quote/Model/Quote/Plugin/UpdateQuoteStoreId.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
}
4141

4242
/**
43-
* Update store id in requested quote by store id from request.
43+
* Update store id in requested quote by store id from guest's request.
4444
*
4545
* @param Quote $subject
4646
* @param Quote $result
@@ -49,12 +49,7 @@ public function __construct(
4949
*/
5050
public function afterLoadByIdWithoutStore(Quote $subject, Quote $result): Quote
5151
{
52-
$storeId = $this->storeManager->getStore()
53-
->getId() ?: $this->storeManager->getDefaultStoreView()
54-
->getId();
55-
$result->setStoreId($storeId);
56-
57-
return $result;
52+
return $this->loadQuote($result);
5853
}
5954

6055
/**
@@ -67,12 +62,7 @@ public function afterLoadByIdWithoutStore(Quote $subject, Quote $result): Quote
6762
*/
6863
public function afterLoadByCustomer(Quote $subject, Quote $result): Quote
6964
{
70-
$store = $this->getStore($this->request->getPathInfo());
71-
if ($store) {
72-
$result->setStoreId($store->getId());
73-
}
74-
75-
return $result;
65+
return $this->loadQuote($result);
7666
}
7767

7868
/**
@@ -89,4 +79,20 @@ private function getStore(string $requestPath): ?StoreInterface
8979

9080
return $stores[$storeCode] ?? null;
9181
}
82+
83+
/**
84+
* Update store id in requested quote by store id from request.
85+
*
86+
* @param Quote $quote
87+
* @return Quote
88+
*/
89+
private function loadQuote(Quote $quote): Quote
90+
{
91+
$store = $this->getStore($this->request->getPathInfo());
92+
if ($store) {
93+
$quote->setStoreId($store->getId());
94+
}
95+
96+
return $quote;
97+
}
9298
}

0 commit comments

Comments
 (0)