Skip to content

Commit a1c9157

Browse files
author
Gabriel Galvao da Gama
committed
Merge branch '2.4.1-develop' of github.com:magento/magento2ce into 2.4.1-develop-MC-37097
2 parents 7bbd5de + 6896ed6 commit a1c9157

File tree

20 files changed

+530
-20
lines changed

20 files changed

+530
-20
lines changed

app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/ConfigurableCartItemOptions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5555

5656
$result = [];
5757
foreach ($this->configurationHelper->getOptions($cartItem) as $option) {
58+
if (isset($option['option_type'])) {
59+
//Don't return customizable options in this resolver
60+
continue;
61+
}
5862
$result[] = [
5963
'id' => $option['option_id'],
6064
'option_label' => $option['label'],

app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ input ConfigurableProductCartItemInput {
5858
}
5959

6060
type ConfigurableCartItem implements CartItemInterface {
61-
customizable_options: [SelectedCustomizableOption]!
61+
customizable_options: [SelectedCustomizableOption] @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\CustomizableOptions")
6262
configurable_options: [SelectedConfigurableOption!]! @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\ConfigurableCartItemOptions")
6363
}
6464

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
namespace Magento\QuoteGraphQl\Model\Cart;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1112
use Magento\GraphQl\Model\Query\ContextInterface;
1213
use Magento\Quote\Api\Data\CartInterface;
14+
use Magento\Quote\Model\QuoteRepository;
1315

1416
/**
1517
* Set single shipping address for a specified shopping cart
@@ -26,16 +28,25 @@ class SetShippingAddressesOnCart implements SetShippingAddressesOnCartInterface
2628
*/
2729
private $getShippingAddress;
2830

31+
/**
32+
* @var QuoteRepository
33+
*/
34+
private $quoteRepository;
35+
2936
/**
3037
* @param AssignShippingAddressToCart $assignShippingAddressToCart
3138
* @param GetShippingAddress $getShippingAddress
39+
* @param QuoteRepository|null $quoteRepository
3240
*/
3341
public function __construct(
3442
AssignShippingAddressToCart $assignShippingAddressToCart,
35-
GetShippingAddress $getShippingAddress
43+
GetShippingAddress $getShippingAddress,
44+
QuoteRepository $quoteRepository = null
3645
) {
3746
$this->assignShippingAddressToCart = $assignShippingAddressToCart;
3847
$this->getShippingAddress = $getShippingAddress;
48+
$this->quoteRepository = $quoteRepository
49+
?? ObjectManager::getInstance()->get(QuoteRepository::class);
3950
}
4051

4152
/**
@@ -70,5 +81,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
7081
throw $e;
7182
}
7283
$this->assignShippingAddressToCart->execute($cart, $shippingAddress);
84+
// trigger quote re-evaluation after address change
85+
$this->quoteRepository->save($cart);
7386
}
7487
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
10+
<arguments>
11+
<argument name="extendedConfigData" xsi:type="array">
12+
<item name="product_reviews_enabled" xsi:type="string">catalog/review/active</item>
13+
<item name="allow_guests_to_write_product_reviews" xsi:type="string">catalog/review/allow_guest</item>
14+
</argument>
15+
</arguments>
16+
</type>
17+
</config>

app/code/Magento/ReviewGraphQl/etc/schema.graphqls

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ type ProductReviewRatingsMetadata {
3939
}
4040

4141
type ProductReviewRatingMetadata {
42-
id: String! @doc(description: "Base64 encoded rating ID.")
42+
id: String! @doc(description: "An encoded rating ID.")
4343
name: String! @doc(description: "The label assigned to an aspect of a product that is being rated, such as quality or price")
4444
values: [ProductReviewRatingValueMetadata!]! @doc(description: "List of product review ratings sorted by position.") @resolver(class: "Magento\\ReviewGraphQl\\Model\\Resolver\\ProductReviewRatingValueMetadata")
4545
}
4646

4747
type ProductReviewRatingValueMetadata {
48-
value_id: String! @doc(description: "Base 64 encoded rating value id.")
49-
value: String! @doc(description: "e.g Good, Perfect, 3, 4, 5")
48+
value_id: String! @doc(description: "An encoded rating value id.")
49+
value: String! @doc(description: "A ratings scale, such as the number of stars awarded")
5050
}
5151

5252
type Customer {
@@ -73,6 +73,11 @@ input CreateProductReviewInput {
7373
}
7474

7575
input ProductReviewRatingInput {
76-
id: String! @doc(description: "Base64 encoded rating ID.")
77-
value_id: String! @doc(description: "Base 64 encoded rating value id.")
76+
id: String! @doc(description: "An encoded rating ID.")
77+
value_id: String! @doc(description: "An encoded rating value id.")
78+
}
79+
80+
type StoreConfig @doc(description: "The type contains information about a store config") {
81+
product_reviews_enabled : String @doc(description: "Indicates whether product reviews are enabled. Possible values: 1 (Yes) and 0 (No)")
82+
allow_guests_to_write_product_reviews : String @doc(description: "Indicates whether guest users can write product reviews. Possible values: 1 (Yes) and 0 (No)")
7883
}

app/code/Magento/Wishlist/Model/Wishlist/AddProductsToWishlist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Wishlist\Model\Wishlist;
99

1010
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1112
use Magento\Framework\Exception\AlreadyExistsException;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Framework\Exception\NoSuchEntityException;
@@ -113,6 +114,12 @@ private function addItemToWishlist(Wishlist $wishlist, WishlistItem $wishlistIte
113114
}
114115

115116
try {
117+
if ((int)$wishlistItem->getQuantity() === 0) {
118+
throw new LocalizedException(__("The quantity of a wish list item cannot be 0"));
119+
}
120+
if ($product->getStatus() == Status::STATUS_DISABLED) {
121+
throw new LocalizedException(__("The product is disabled"));
122+
}
116123
$options = $this->buyRequestBuilder->build($wishlistItem, (int) $product->getId());
117124
$result = $wishlist->addNewItem($product, $options);
118125

app/code/Magento/Wishlist/Model/Wishlist/UpdateProductsInWishlist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Wishlist\Model\Wishlist;
99

10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1011
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Wishlist\Model\Item as WishlistItem;
1213
use Magento\Wishlist\Model\ItemFactory as WishlistItemFactory;
@@ -95,6 +96,12 @@ private function updateItemInWishlist(Wishlist $wishlist, WishlistItemData $wish
9596
$wishlistItem = $this->wishlistItemFactory->create();
9697
$this->wishlistItemResource->load($wishlistItem, $wishlistItemData->getId());
9798
$wishlistItem->setDescription($wishlistItemData->getDescription());
99+
if ((int)$wishlistItemData->getQuantity() === 0) {
100+
throw new LocalizedException(__("The quantity of a wish list item cannot be 0"));
101+
}
102+
if ($wishlistItem->getProduct()->getStatus() == Status::STATUS_DISABLED) {
103+
throw new LocalizedException(__("The product is disabled"));
104+
}
98105
$resultItem = $wishlist->updateItem($wishlistItem, $options);
99106

100107
if (is_string($resultItem)) {

app/code/Magento/WishlistGraphQl/Model/Resolver/AddProductsToWishlist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function resolve(
8383
array $args = null
8484
) {
8585
if (!$this->wishlistConfig->isEnabled()) {
86-
throw new GraphQlInputException(__('The wishlist is not currently available.'));
86+
throw new GraphQlInputException(__('The wishlist configuration is currently disabled.'));
8787
}
8888

8989
$customerId = $context->getUserId();

app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function resolve(
5454
array $args = null
5555
) {
5656
if (!$this->wishlistConfig->isEnabled()) {
57-
throw new GraphQlInputException(__('The wishlist is not currently available.'));
57+
throw new GraphQlInputException(__('The wishlist configuration is currently disabled.'));
5858
}
5959

6060
if (false === $context->getExtensionAttributes()->getIsCustomer()) {

app/code/Magento/WishlistGraphQl/Model/Resolver/RemoveProductsFromWishlist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function resolve(
8383
array $args = null
8484
) {
8585
if (!$this->wishlistConfig->isEnabled()) {
86-
throw new GraphQlInputException(__('The wishlist is not currently available.'));
86+
throw new GraphQlInputException(__('The wishlist configuration is currently disabled.'));
8787
}
8888

8989
$customerId = $context->getUserId();

0 commit comments

Comments
 (0)