diff --git a/vendor/magento/module-gift-message/Model/GuestCartRepository.php b/vendor/magento/module-gift-message/Model/GuestCartRepository.php index 96cd8e0f6c32c..eba7a892ef444 100644 --- a/vendor/magento/module-gift-message/Model/GuestCartRepository.php +++ b/vendor/magento/module-gift-message/Model/GuestCartRepository.php @@ -11,6 +11,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 @@ -28,34 +30,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 79545b6d6f9c9..6421895f534a7 100644 --- a/vendor/magento/module-gift-message/Model/GuestItemRepository.php +++ b/vendor/magento/module-gift-message/Model/GuestItemRepository.php @@ -11,6 +11,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 @@ -28,34 +30,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); } }