diff --git a/vendor/magento/module-gift-message/Model/GuestCartRepository.php b/vendor/magento/module-gift-message/Model/GuestCartRepository.php index c118433251fdf..1ad7b5aa4e1d6 100644 --- a/vendor/magento/module-gift-message/Model/GuestCartRepository.php +++ b/vendor/magento/module-gift-message/Model/GuestCartRepository.php @@ -10,6 +10,8 @@ use Magento\GiftMessage\Api\GuestCartRepositoryInterface; use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\Framework\App\ObjectManager; +use Magento\Quote\Model\GuestCart\GetGuestCart; /** * Shopping cart gift message repository object for guest @@ -27,34 +29,45 @@ class GuestCartRepository implements GuestCartRepositoryInterface protected $quoteIdMaskFactory; + /** + * @var GetGuestCart|null + */ + private $getGuestCart; + /** * @param CartRepository $repository * @param QuoteIdMaskFactory $quoteIdMaskFactory + * @param GetGuestCart|null $getGuestCart */ public function __construct( CartRepository $repository, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdMaskFactory $quoteIdMaskFactory, + ?GetGuestCart $getGuestCart = null ) { $this->repository = $repository; $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->getGuestCart = $getGuestCart ?? ObjectManager::getInstance()->get(GetGuestCart::class); } /** - * {@inheritDoc} + * @inheritDoc */ public function get($cartId) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); - return $this->repository->get($quoteIdMask->getQuoteId()); + $this->getGuestCart->execute($cartId, (int) $quoteIdMask->getQuoteId()); + $quote = $this->repository->get($quoteIdMask->getQuoteId()); + return $quote; } /** - * {@inheritDoc} + * @inheritDoc */ public function save($cartId, MessageInterface $giftMessage) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + $this->getGuestCart->execute($cartId, (int) $quoteIdMask->getQuoteId()); return $this->repository->save($quoteIdMask->getQuoteId(), $giftMessage); } } diff --git a/vendor/magento/module-gift-message/Model/GuestItemRepository.php b/vendor/magento/module-gift-message/Model/GuestItemRepository.php index 09fe21382a966..d502e979f6581 100644 --- a/vendor/magento/module-gift-message/Model/GuestItemRepository.php +++ b/vendor/magento/module-gift-message/Model/GuestItemRepository.php @@ -10,6 +10,8 @@ use Magento\GiftMessage\Api\GuestItemRepositoryInterface; use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\Framework\App\ObjectManager; +use Magento\Quote\Model\GuestCart\GetGuestCart; /** * Shopping cart gift message item repository object for guest @@ -27,34 +29,45 @@ class GuestItemRepository implements GuestItemRepositoryInterface protected $quoteIdMaskFactory; + /** + * @var GetGuestCart|null + */ + private $getGuestCart; + /** * @param ItemRepository $repository * @param QuoteIdMaskFactory $quoteIdMaskFactory + * @param GetGuestCart|null $getGuestCart */ public function __construct( ItemRepository $repository, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdMaskFactory $quoteIdMaskFactory, + ?GetGuestCart $getGuestCart = null ) { $this->repository = $repository; $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->getGuestCart = $getGuestCart ?? ObjectManager::getInstance()->get(GetGuestCart::class); } /** - * {@inheritDoc} + * @inheritDoc */ public function get($cartId, $itemId) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); - return $this->repository->get($quoteIdMask->getQuoteId(), $itemId); + $this->getGuestCart->execute($cartId, (int) $quoteIdMask->getQuoteId()); + $quoteItem = $this->repository->get($quoteIdMask->getQuoteId(), $itemId); + return $quoteItem; } /** - * {@inheritDoc} + * @inheritDoc */ public function save($cartId, MessageInterface $giftMessage, $itemId) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + $this->getGuestCart->execute($cartId, (int) $quoteIdMask->getQuoteId()); return $this->repository->save($quoteIdMask->getQuoteId(), $giftMessage, $itemId); } }