Skip to content

Commit 941caff

Browse files
committed
MC-22215: Add customerCart Query and cart_id changes to schema and related resolvers
- Demo maskedid fixtures
1 parent e5163a8 commit 941caff

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Magento\GraphQl\Model\Query\ContextInterface;
1616
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1717
use Magento\Quote\Api\CartManagementInterface;
18+
use Magento\Quote\Model\QuoteIdMaskFactory;
19+
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
20+
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
1821

1922
/**
2023
* Get cart for the customer
@@ -31,16 +34,39 @@ class CustomerCart implements ResolverInterface
3134
*/
3235
private $cartManagement;
3336

37+
/**
38+
* @var QuoteIdMaskFactory
39+
*/
40+
private $quoteIdMaskFactory;
41+
42+
/**
43+
* @var QuoteIdMaskResourceModel
44+
*/
45+
private $quoteIdMaskResourceModel;
46+
/**
47+
* @var QuoteIdToMaskedQuoteIdInterface
48+
*/
49+
private $quoteIdToMaskedQuoteId;
50+
3451
/**
3552
* @param CreateEmptyCartForCustomer $createEmptyCartForCustomer
3653
* @param CartManagementInterface $cartManagement
54+
* @param QuoteIdMaskFactory $quoteIdMaskFactory
55+
* @param QuoteIdMaskResourceModel $quoteIdMaskResourceModel
56+
* @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
3757
*/
3858
public function __construct(
3959
CreateEmptyCartForCustomer $createEmptyCartForCustomer,
40-
CartManagementInterface $cartManagement
60+
CartManagementInterface $cartManagement,
61+
QuoteIdMaskFactory $quoteIdMaskFactory,
62+
QuoteIdMaskResourceModel $quoteIdMaskResourceModel,
63+
QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
4164
) {
4265
$this->createEmptyCartForCustomer = $createEmptyCartForCustomer;
4366
$this->cartManagement = $cartManagement;
67+
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
68+
$this->quoteIdMaskResourceModel = $quoteIdMaskResourceModel;
69+
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId;
4470
}
4571

4672
/**
@@ -61,6 +87,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6187
$cart = $this->cartManagement->getCartForCustomer($currentUserId);
6288
}
6389

90+
$maskedId = $this->quoteIdToMaskedQuoteId->execute((int) $cart->getId());
91+
if (empty($maskedId)) {
92+
$quoteIdMask = $this->quoteIdMaskFactory->create();
93+
$quoteIdMask->setQuoteId((int) $cart->getId());
94+
$this->quoteIdMaskResourceModel->save($quoteIdMask);
95+
}
96+
6497
return [
6598
'model' => $cart
6699
];

0 commit comments

Comments
 (0)