|
15 | 15 | use Magento\Framework\App\ObjectManager;
|
16 | 16 | use Magento\Framework\Data\CollectionFactory;
|
17 | 17 | use Magento\Framework\Data\FormFactory;
|
| 18 | +use Magento\Framework\Exception\LocalizedException; |
18 | 19 | use Magento\Framework\Exception\NoSuchEntityException;
|
19 | 20 | use Magento\Framework\Registry;
|
20 | 21 | use Magento\Quote\Api\CartRepositoryInterface;
|
|
32 | 33 | class Cart extends Extended
|
33 | 34 | {
|
34 | 35 | /**
|
35 |
| - * Core registry |
36 |
| - * |
37 | 36 | * @var Registry
|
38 | 37 | */
|
39 | 38 | protected $_coreRegistry = null;
|
@@ -266,16 +265,16 @@ public function getRowUrl($row)
|
266 | 265 | /**
|
267 | 266 | * Get the quote of the cart
|
268 | 267 | *
|
269 |
| - * @return \Magento\Quote\Model\Quote |
| 268 | + * @return Quote |
| 269 | + * @throws LocalizedException |
270 | 270 | */
|
271 | 271 | protected function getQuote()
|
272 | 272 | {
|
273 | 273 | if (null === $this->quote) {
|
274 | 274 | $customerId = $this->getCustomerId();
|
275 | 275 | $websiteId = $this->getWebsiteId() ?:
|
276 | 276 | $this->_storeManager->getDefaultStoreView()->getWebsiteId();
|
277 |
| - $storeIds = $this->_storeManager->getWebsite($websiteId)->getStoreIds(); |
278 |
| - |
| 277 | + $storeIds = $this->getAssociatedStoreIds((int) $websiteId); |
279 | 278 | try {
|
280 | 279 | $this->quote = $this->quoteRepository->getForCustomer($customerId, $storeIds);
|
281 | 280 | } catch (NoSuchEntityException $e) {
|
@@ -334,4 +333,20 @@ private function getWebsiteFilterHtml(): string
|
334 | 333 | {
|
335 | 334 | return $this->getChildHtml('website_filter_block');
|
336 | 335 | }
|
| 336 | + |
| 337 | + /** |
| 338 | + * Get website associated store IDs |
| 339 | + * |
| 340 | + * @param int $websiteId |
| 341 | + * @return array |
| 342 | + * @throws LocalizedException |
| 343 | + */ |
| 344 | + private function getAssociatedStoreIds(int $websiteId): array |
| 345 | + { |
| 346 | + $storeIds = $this->_storeManager->getWebsite($websiteId)->getStoreIds(); |
| 347 | + if (empty($this->getWebsiteId()) && !empty($this->_storeManager->getWebsite()->getStoreIds())) { |
| 348 | + $storeIds = $this->_storeManager->getWebsite()->getStoreIds(); |
| 349 | + } |
| 350 | + return $storeIds; |
| 351 | + } |
337 | 352 | }
|
0 commit comments