From 88778bdaa8797e221490f360799760e872495f88 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Wed, 10 Jun 2020 14:09:57 +0300 Subject: [PATCH] magento/magento2#23972 fix disabled guest checkout issue --- .../Observer/IsAllowedGuestCheckoutObserver.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php b/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php index b24cddd845c9c..6e42f73c0f95c 100644 --- a/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php +++ b/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php @@ -15,6 +15,7 @@ use Magento\Quote\Api\Data\CartItemInterface; use Magento\Quote\Model\Quote; use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\StoreManagerInterface; /** * Checks if guest checkout is allowed then quote contains downloadable products. @@ -36,14 +37,25 @@ class IsAllowedGuestCheckoutObserver implements ObserverInterface * @var LinkCollectionFactory */ private $linkCollectionFactory; + + /** + * @var StoreManagerInterface + */ + private $storeManager; /** * @param ScopeConfigInterface $scopeConfig * @param LinkCollectionFactory $linkCollectionFactory + * @param StoreManagerInterface $storeManager */ - public function __construct(ScopeConfigInterface $scopeConfig, LinkCollectionFactory $linkCollectionFactory) { + public function __construct( + ScopeConfigInterface $scopeConfig, + LinkCollectionFactory $linkCollectionFactory, + StoreManagerInterface $storeManager + ) { $this->scopeConfig = $scopeConfig; $this->linkCollectionFactory = $linkCollectionFactory; + $this->storeManager = $storeManager; } /** @@ -54,7 +66,7 @@ public function __construct(ScopeConfigInterface $scopeConfig, LinkCollectionFac */ public function execute(Observer $observer) { - $storeId = (int)$observer->getEvent()->getStore()->getId(); + $storeId = (int)$this->storeManager->getStore($observer->getEvent()->getStore())->getId(); $result = $observer->getEvent()->getResult(); /* @var $quote Quote */