Skip to content

Commit 0fadeff

Browse files
authored
Merge branch '2.4-develop' into fix-issue-27162-sort-order-link-incorrect-compare
2 parents 1e22f3d + ad41c3b commit 0fadeff

File tree

54 files changed

+3878
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3878
-223
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category/AggregateCount.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
use Magento\Catalog\Model\Category;
99

1010
/**
11+
* Aggregate count for parent category after deleting child category
12+
*
1113
* Class AggregateCount
1214
*/
1315
class AggregateCount
1416
{
1517
/**
18+
* Reduces children count for parent categories
19+
*
1620
* @param Category $category
1721
* @return void
1822
*/
@@ -25,9 +29,7 @@ public function processDelete(Category $category)
2529
*/
2630
$parentIds = $category->getParentIds();
2731
if ($parentIds) {
28-
$childDecrease = $category->getChildrenCount() + 1;
29-
// +1 is itself
30-
$data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)];
32+
$data = ['children_count' => new \Zend_Db_Expr('children_count - 1')];
3133
$where = ['entity_id IN(?)' => $parentIds];
3234
$resourceModel->getConnection()->update($resourceModel->getEntityTable(), $data, $where);
3335
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category;
9+
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Catalog\Model\ResourceModel\Category\AggregateCount;
12+
use Magento\Catalog\Model\ResourceModel\Category as ResourceCategory;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15+
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Aggregate count model test
20+
*/
21+
class AggregateCountTest extends TestCase
22+
{
23+
24+
/**
25+
* @var AggregateCount
26+
*/
27+
protected $aggregateCount;
28+
29+
/**
30+
* @var ObjectManagerHelper
31+
*/
32+
protected $objectManagerHelper;
33+
34+
/**
35+
* @var Category|MockObject
36+
*/
37+
protected $categoryMock;
38+
39+
/**
40+
* @var ResourceCategory|MockObject
41+
*/
42+
protected $resourceCategoryMock;
43+
44+
/**
45+
* @var AdapterInterface|MockObject
46+
*/
47+
protected $connectionMock;
48+
49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function setUp(): void
53+
{
54+
$this->categoryMock = $this->createMock(Category::class);
55+
$this->resourceCategoryMock = $this->createMock(ResourceCategory::class);
56+
$this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
57+
->getMockForAbstractClass();
58+
$this->objectManagerHelper = new ObjectManagerHelper($this);
59+
$this->aggregateCount = $this->objectManagerHelper->getObject(AggregateCount::class);
60+
}
61+
62+
/**
63+
* @return void
64+
*/
65+
public function testProcessDelete(): void
66+
{
67+
$parentIds = 3;
68+
$table = 'catalog_category_entity';
69+
70+
$this->categoryMock->expects($this->once())
71+
->method('getResource')
72+
->willReturn($this->resourceCategoryMock);
73+
$this->categoryMock->expects($this->once())
74+
->method('getParentIds')
75+
->willReturn($parentIds);
76+
$this->resourceCategoryMock->expects($this->any())
77+
->method('getEntityTable')
78+
->willReturn($table);
79+
$this->resourceCategoryMock->expects($this->once())
80+
->method('getConnection')
81+
->willReturn($this->connectionMock);
82+
$this->connectionMock->expects($this->once())
83+
->method('update')
84+
->with(
85+
$table,
86+
['children_count' => new \Zend_Db_Expr('children_count - 1')],
87+
['entity_id IN(?)' => $parentIds]
88+
);
89+
$this->aggregateCount->processDelete($this->categoryMock);
90+
}
91+
}

app/code/Magento/Customer/Block/DataProviders/AddressAttributeData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getFrontendLabel(string $attributeCode): string
5252
{
5353
try {
5454
$attribute = $this->addressMetadata->getAttributeMetadata($attributeCode);
55-
$frontendLabel = $attribute->getFrontendLabel();
55+
$frontendLabel = $attribute->getStoreLabel() ?: $attribute->getFrontendLabel();
5656
} catch (NoSuchEntityException $e) {
5757
$frontendLabel = '';
5858
}

app/code/Magento/GiftMessageGraphQl/Model/Resolver/Cart/GiftMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function resolve(
6666
array $args = null
6767
) {
6868
if (!isset($value['model'])) {
69-
throw new GraphQlInputException(__('"model" value should be specified'));
69+
throw new GraphQlInputException(__('"model" value must be specified'));
7070
}
7171

7272
$cart = $value['model'];
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GiftMessageGraphQl\Model\Resolver\Cart\Item;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
13+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
14+
use Magento\Framework\GraphQl\Query\Resolver\Value;
15+
use Magento\Framework\GraphQl\Query\ResolverInterface;
16+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17+
use Magento\GiftMessage\Api\ItemRepositoryInterface;
18+
use Magento\GiftMessage\Helper\Message as GiftMessageHelper;
19+
20+
/**
21+
* Class provides ability to get GiftMessage for cart item
22+
*/
23+
class GiftMessage implements ResolverInterface
24+
{
25+
/**
26+
* @var ItemRepositoryInterface
27+
*/
28+
private $itemRepository;
29+
30+
/**
31+
* @var GiftMessageHelper
32+
*/
33+
private $giftMessageHelper;
34+
35+
/**
36+
* @param ItemRepositoryInterface $itemRepository
37+
* @param GiftMessageHelper $giftMessageHelper
38+
*/
39+
public function __construct(
40+
ItemRepositoryInterface $itemRepository,
41+
GiftMessageHelper $giftMessageHelper
42+
) {
43+
$this->itemRepository = $itemRepository;
44+
$this->giftMessageHelper = $giftMessageHelper;
45+
}
46+
47+
/**
48+
* Return information about Gift message for item cart
49+
*
50+
* @param Field $field
51+
* @param ContextInterface $context
52+
* @param ResolveInfo $info
53+
* @param array|null $value
54+
* @param array|null $args
55+
*
56+
* @return array|Value|mixed
57+
* @throws GraphQlInputException
58+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
59+
*/
60+
public function resolve(
61+
Field $field,
62+
$context,
63+
ResolveInfo $info,
64+
array $value = null,
65+
array $args = null
66+
) {
67+
if (!isset($value['model'])) {
68+
throw new GraphQlInputException(__('"model" value must be specified'));
69+
}
70+
71+
$quoteItem = $value['model'];
72+
73+
if (!$this->giftMessageHelper->isMessagesAllowed('items', $quoteItem)) {
74+
return null;
75+
}
76+
77+
if (!$this->giftMessageHelper->isMessagesAllowed('item', $quoteItem)) {
78+
return null;
79+
}
80+
81+
try {
82+
$giftItemMessage = $this->itemRepository->get($quoteItem->getQuoteId(), $quoteItem->getItemId());
83+
} catch (LocalizedException $e) {
84+
throw new GraphQlInputException(__('Can\'t load cart item'));
85+
}
86+
87+
if (!isset($giftItemMessage)) {
88+
return null;
89+
}
90+
91+
return [
92+
'to' => $giftItemMessage->getRecipient() ?? '',
93+
'from' => $giftItemMessage->getSender() ?? '',
94+
'message'=> $giftItemMessage->getMessage() ?? ''
95+
];
96+
}
97+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# GiftMessageGraphQl
22

3-
**GiftMessageGraphQl** provides information about gift messages for cart, cart items, order and order items.
3+
**GiftMessageGraphQl** provides information about gift messages for carts, cart items, orders and order items.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
10+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
11+
<arguments>
12+
<argument name="extendedConfigData" xsi:type="array">
13+
<item name="allow_order" xsi:type="string">sales/gift_options/allow_order</item>
14+
<item name="allow_items" xsi:type="string">sales/gift_options/allow_items</item>
15+
</argument>
16+
</arguments>
17+
</type>
18+
</config>
Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,47 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33

4+
type StoreConfig {
5+
allow_order : String @doc(description: "The value of the Allow Gift Messages on Order Level option")
6+
allow_items : String @doc(description: "The value of the Allow Gift Messages for Order Items option")
7+
}
8+
49
type Cart {
510
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Cart\\GiftMessage") @doc(description: "The entered gift message for the cart")
611
}
712

8-
type SalesItemInterface {
9-
gift_message: GiftMessage @doc(description: "The entered gift message for the order item")
13+
type SimpleCartItem {
14+
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Cart\\Item\\GiftMessage") @doc(description: "The entered gift message for the cart item")
1015
}
1116

12-
type CustomerOrder {
13-
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Order\\GiftMessage") @doc(description: "The entered gift message for the order")
17+
type ConfigurableCartItem {
18+
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Cart\\Item\\GiftMessage") @doc(description: "The entered gift message for the cart item")
19+
}
20+
21+
type BundleCartItem {
22+
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Cart\\Item\\GiftMessage") @doc(description: "The entered gift message for the cart item")
23+
}
24+
25+
type GiftMessage @doc(description: "Contains the text of a gift message, its sender, and recipient") {
26+
to: String! @doc(description: "Recipient name")
27+
from: String! @doc(description: "Sender name")
28+
message: String! @doc(description: "Gift message text")
29+
}
30+
31+
input CartItemUpdateInput {
32+
gift_message: GiftMessageInput @doc(description: "Gift message details for the cart item")
1433
}
1534

16-
type GiftMessage {
17-
to: String! @doc(description: "Recepient name")
35+
input GiftMessageInput @doc(description: "Contains the text of a gift message, its sender, and recipient") {
36+
to: String! @doc(description: "Recipient name")
1837
from: String! @doc(description: "Sender name")
1938
message: String! @doc(description: "Gift message text")
2039
}
40+
41+
type SalesItemInterface {
42+
gift_message: GiftMessage @doc(description: "The entered gift message for the order item")
43+
}
44+
45+
type CustomerOrder {
46+
gift_message: GiftMessage @resolver (class: "\\Magento\\GiftMessageGraphQl\\Model\\Resolver\\Order\\GiftMessage") @doc(description: "The entered gift message for the order")
47+
}

0 commit comments

Comments
 (0)