diff --git a/vendor/magento/module-shared-catalog/Plugin/AdvancedCheckout/Model/HideProductsAbsentInSharedCatalogPlugin.php b/vendor/magento/module-shared-catalog/Plugin/AdvancedCheckout/Model/HideProductsAbsentInSharedCatalogPlugin.php index 00f8752122d6..a14bc3387e9a 100644 --- a/vendor/magento/module-shared-catalog/Plugin/AdvancedCheckout/Model/HideProductsAbsentInSharedCatalogPlugin.php +++ b/vendor/magento/module-shared-catalog/Plugin/AdvancedCheckout/Model/HideProductsAbsentInSharedCatalogPlugin.php @@ -15,9 +15,12 @@ use Magento\SharedCatalog\Model\SharedCatalogResolver; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; +use Magento\Customer\Model\Session; /** * Plugin for the AdvancedCheckout Cart model to change item status on not found. + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class HideProductsAbsentInSharedCatalogPlugin { @@ -41,22 +44,30 @@ class HideProductsAbsentInSharedCatalogPlugin */ private $sharedCatalogProductCollectionFactory; + /** + * @var \Magento\Customer\Model\Session + */ + private $customerSession; + /** * @param StatusInfoInterface $config * @param StoreManagerInterface $storeManager * @param SharedCatalogResolver $sharedCatalogResolver * @param CollectionFactory $sharedCatalogProductCollectionFactory + * @param Session $customerSession */ public function __construct( StatusInfoInterface $config, StoreManagerInterface $storeManager, SharedCatalogResolver $sharedCatalogResolver, - CollectionFactory $sharedCatalogProductCollectionFactory + CollectionFactory $sharedCatalogProductCollectionFactory, + Session $customerSession ) { $this->config = $config; $this->storeManager = $storeManager; $this->sharedCatalogResolver = $sharedCatalogResolver; $this->sharedCatalogProductCollectionFactory = $sharedCatalogProductCollectionFactory; + $this->customerSession = $customerSession; } /** @@ -71,7 +82,7 @@ public function afterCheckItems(Cart $subject, array $items): array { $website = $this->storeManager->getWebsite()->getId(); if ($this->config->isActive(ScopeInterface::SCOPE_WEBSITE, $website)) { - $customer = $subject->getActualQuote()->getCustomer(); + $customer = $this->customerSession->getCustomer(); $groupId = $customer && $customer->getId() ? (int) $customer->getGroupId() : GroupManagement::NOT_LOGGED_IN_ID;