Skip to content

Commit 55b6f4e

Browse files
author
vitaliyboyko
committed
graphQl: fixed SetShippingAddressesInterface param
1 parent e1f09fb commit 55b6f4e

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use InvalidArgumentException;
1111
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
12+
use Magento\Quote\Api\Data\CartInterface;
1213

1314
/**
1415
* Set shipping addresses for shopping cart processors chain
@@ -32,7 +33,7 @@ public function __construct(
3233
/**
3334
* @inheritdoc
3435
*/
35-
public function execute(ContextInterface $context, int $cartId, array $shippingAddresses): void
36+
public function execute(ContextInterface $context, CartInterface $cart, array $shippingAddresses): void
3637
{
3738
foreach ($this->shippingAddressProcessors as $shippingAddressProcessor) {
3839
if (!$shippingAddressProcessor instanceof SetShippingAddressesOnCartInterface) {
@@ -42,7 +43,7 @@ public function execute(ContextInterface $context, int $cartId, array $shippingA
4243
);
4344
}
4445

45-
$shippingAddressProcessor->execute($context, $cartId, $shippingAddresses);
46+
$shippingAddressProcessor->execute($context, $cart, $shippingAddresses);
4647
}
4748
}
4849
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart/SingleShippingAddressProcessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1414
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
15+
use Magento\Quote\Api\Data\CartInterface;
1516
use Magento\Quote\Model\Quote\Address;
1617
use Magento\Quote\Model\ShippingAddressManagementInterface;
1718
use Magento\Customer\Api\AddressRepositoryInterface;
@@ -55,7 +56,7 @@ public function __construct(
5556
/**
5657
* @inheritdoc
5758
*/
58-
public function execute(ContextInterface $context, int $cartId, array $shippingAddresses): void
59+
public function execute(ContextInterface $context, CartInterface $cart, array $shippingAddresses): void
5960
{
6061
if (count($shippingAddresses) > 1) {
6162
return;
@@ -89,6 +90,6 @@ public function execute(ContextInterface $context, int $cartId, array $shippingA
8990
$shippingAddress = $this->addressModel->addData($addressInput);
9091
}
9192

92-
$this->shippingAddressManagement->assign($cartId, $shippingAddress);
93+
$this->shippingAddressManagement->assign($cart->getId(), $shippingAddress);
9394
}
9495
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCartInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1111
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
12+
use Magento\Quote\Api\Data\CartInterface;
1213

1314
/**
1415
* Extension point for setting shipping addresses for a specified shopping cart
@@ -22,10 +23,10 @@ interface SetShippingAddressesOnCartInterface
2223
* Set shipping addresses for a specified shopping cart
2324
*
2425
* @param ContextInterface $context
25-
* @param int $cartId
26+
* @param CartInterface $cart
2627
* @param array $shippingAddresses
2728
* @return void
2829
* @throws GraphQlInputException
2930
*/
30-
public function execute(ContextInterface $context, int $cartId, array $shippingAddresses): void;
31+
public function execute(ContextInterface $context, CartInterface $cart, array $shippingAddresses): void;
3132
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8787

8888
$maskedCartId = $args['input']['cart_id'];
8989
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId());
90-
$cartId = (int)$cart->getEntityId();
9190

92-
$this->setShippingAddressesOnCart->execute($context, $cartId, $shippingAddresses);
91+
$this->setShippingAddressesOnCart->execute($context, $cart, $shippingAddresses);
9392

9493
return [
9594
'cart' => [

0 commit comments

Comments
 (0)