Skip to content

Commit c471314

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-commerce/magento2ce into T4-02-16-2024
2 parents cc46f0d + c26aca7 commit c471314

File tree

45 files changed

+873
-310
lines changed

Some content is hidden

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

45 files changed

+873
-310
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class Menu extends \Magento\Backend\Block\Template
2020
{
21-
const CACHE_TAGS = 'BACKEND_MAINMENU';
21+
public const CACHE_TAGS = 'BACKEND_MAINMENU';
2222

2323
/**
2424
* @var string
@@ -347,6 +347,11 @@ protected function _columnBrake($items, $limit)
347347
}
348348
$result[] = ['place' => $place, 'colbrake' => $colbrake];
349349
}
350+
351+
if (isset($result[1]) && $result[1]['colbrake'] === true && isset($result[2])) {
352+
$result[2]['colbrake'] = true;
353+
}
354+
350355
return $result;
351356
}
352357

app/code/Magento/Backend/Console/Command/CacheCleanCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CacheCleanCommand extends AbstractCacheTypeManageCommand
1616
{
1717
/**
18-
* {@inheritdoc}
18+
* @inheritdoc
1919
*/
2020
protected function configure()
2121
{
@@ -32,12 +32,15 @@ protected function configure()
3232
*/
3333
protected function performAction(array $cacheTypes)
3434
{
35-
$this->eventManager->dispatch('adminhtml_cache_flush_system');
35+
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
36+
$this->eventManager->dispatch('adminhtml_cache_flush_system');
37+
}
38+
3639
$this->cacheManager->clean($cacheTypes);
3740
}
3841

3942
/**
40-
* {@inheritdoc}
43+
* @inheritdoc
4144
*/
4245
protected function getDisplayMessage()
4346
{

app/code/Magento/Backend/Console/Command/CacheFlushCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CacheFlushCommand extends AbstractCacheTypeManageCommand
1616
{
1717
/**
18-
* {@inheritdoc}
18+
* @inheritdoc
1919
*/
2020
protected function configure()
2121
{
@@ -32,12 +32,15 @@ protected function configure()
3232
*/
3333
protected function performAction(array $cacheTypes)
3434
{
35-
$this->eventManager->dispatch('adminhtml_cache_flush_all');
35+
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
36+
$this->eventManager->dispatch('adminhtml_cache_flush_all');
37+
}
38+
3639
$this->cacheManager->flush($cacheTypes);
3740
}
3841

3942
/**
40-
* {@inheritdoc}
43+
* @inheritdoc
4144
*/
4245
protected function getDisplayMessage()
4346
{

app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ public function executeDataProvider()
3535
return [
3636
'implicit all' => [
3737
[],
38-
['A', 'B', 'C'],
39-
$this->getExpectedExecutionOutput(['A', 'B', 'C']),
38+
['A', 'B', 'C', 'full_page'],
39+
true,
40+
$this->getExpectedExecutionOutput(['A', 'B', 'C', 'full_page']),
4041
],
4142
'specified types' => [
4243
['types' => ['A', 'B']],
4344
['A', 'B'],
45+
false,
4446
$this->getExpectedExecutionOutput(['A', 'B']),
4547
],
48+
'fpc_only' => [
49+
['types' => ['full_page']],
50+
['full_page'],
51+
true,
52+
$this->getExpectedExecutionOutput(['full_page']),
53+
],
4654
];
4755
}
4856

app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ protected function setUp(): void
2222
/**
2323
* @param array $param
2424
* @param array $types
25+
* @param bool $shouldDispatch
2526
* @param string $output
2627
* @dataProvider executeDataProvider
2728
*/
28-
public function testExecute($param, $types, $output)
29+
public function testExecute($param, $types, $shouldDispatch, $output)
2930
{
30-
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
31+
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
32+
'A', 'B', 'C', 'full_page'
33+
]);
3134
$this->cacheManagerMock->expects($this->once())->method('clean')->with($types);
32-
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
35+
36+
if ($shouldDispatch) {
37+
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
38+
} else {
39+
$this->eventManagerMock->expects($this->never())->method('dispatch');
40+
}
3341

3442
$commandTester = new CommandTester($this->command);
3543
$commandTester->execute($param);

app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ protected function setUp(): void
2222
/**
2323
* @param array $param
2424
* @param array $types
25+
* @param bool $shouldDispatch
2526
* @param string $output
2627
* @dataProvider executeDataProvider
2728
*/
28-
public function testExecute($param, $types, $output)
29+
public function testExecute($param, $types, $shouldDispatch, $output)
2930
{
30-
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
31+
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
32+
'A', 'B', 'C', 'full_page'
33+
]);
3134
$this->cacheManagerMock->expects($this->once())->method('flush')->with($types);
32-
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
35+
36+
if ($shouldDispatch) {
37+
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
38+
} else {
39+
$this->eventManagerMock->expects($this->never())->method('dispatch');
40+
}
3341

3442
$commandTester = new CommandTester($this->command);
3543
$commandTester->execute($param);

app/code/Magento/Bundle/Test/Mftf/Test/AdminBundleDynamicAttributesAfterMassUpdateTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<argument name="consumerName" value="{{AdminProductAttributeUpdateConsumerData.consumerName}}"/>
4848
<argument name="maxMessages" value="{{AdminProductAttributeUpdateConsumerData.messageLimit}}"/>
4949
</actionGroup>
50-
<magentoCron stepKey="runCron"/>
50+
<magentoCron groups="default" stepKey="runCron"/>
5151

5252
<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="openProductForEdit"/>
5353

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontVerifyProductAfterPartialReindexOnSeveralWebsitesTest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@
8787
<argument name="productName" value="{{_defaultProduct.name}}"/>
8888
</actionGroup>
8989

90-
<!-- Run cron -->
91-
<magentoCron stepKey="runCron" />
92-
<magentoCron stepKey="runCronTwice" />
90+
<!-- We need the 'indexer_update_all_views' job to run. This is the best
91+
way we can make that happen, but there is no guarantee that there is
92+
such a job already scheduled in the queue. -->
93+
<magentoCron groups="index" stepKey="runCron" />
94+
<comment userInput="We need the indexer_update_all_views job to run" stepKey="runCronTwice"/>
9395

9496
<!-- Check product is present in category after cron run -->
9597
<actionGroup ref="AssertProductInStorefrontCategoryPage" stepKey="assertProductInStorefront1">
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\QuoteGraphQl\Model\CartItem;
18+
19+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
20+
use Magento\Framework\GraphQl\Query\Uid;
21+
use Magento\Quote\Api\Data\CartItemInterface;
22+
23+
class GetItemsData
24+
{
25+
/**
26+
* @param Uid $uidEncoder
27+
*/
28+
public function __construct(
29+
private readonly Uid $uidEncoder,
30+
) {
31+
}
32+
33+
/**
34+
* Retrieve cart items data
35+
*
36+
* @param CartItemInterface[] $cartItems
37+
* @return array
38+
*/
39+
public function execute(array $cartItems): array
40+
{
41+
$itemsData = [];
42+
foreach ($cartItems as $cartItem) {
43+
$product = $cartItem->getProduct();
44+
if ($product === null) {
45+
$itemsData[] = new GraphQlNoSuchEntityException(
46+
__("The product that was requested doesn't exist. Verify the product and try again.")
47+
);
48+
continue;
49+
}
50+
$productData = $product->getData();
51+
$productData['model'] = $product;
52+
$productData['uid'] = $this->uidEncoder->encode((string) $product->getId());
53+
54+
$itemsData[] = [
55+
'id' => $cartItem->getItemId(),
56+
'uid' => $this->uidEncoder->encode((string) $cartItem->getItemId()),
57+
'quantity' => $cartItem->getQty(),
58+
'product' => $productData,
59+
'model' => $cartItem,
60+
];
61+
}
62+
return $itemsData;
63+
}
64+
}

app/code/Magento/QuoteGraphQl/Model/CartItem/GetPaginatedCartItems.php

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
namespace Magento\QuoteGraphQl\Model\CartItem;
1818

19-
use Magento\Catalog\Api\Data\ProductInterface;
20-
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
2119
use Magento\Quote\Model\Quote;
2220
use Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory as ItemCollectionFactory;
2321

@@ -27,35 +25,13 @@
2725
class GetPaginatedCartItems
2826
{
2927
/**
30-
* @param ProductCollectionFactory $productCollectionFactory
3128
* @param ItemCollectionFactory $itemCollectionFactory
3229
*/
3330
public function __construct(
34-
private readonly ProductCollectionFactory $productCollectionFactory,
3531
private readonly ItemCollectionFactory $itemCollectionFactory
3632
) {
3733
}
3834

39-
/**
40-
* Get product models based on items in cart
41-
*
42-
* @param array $cartProductsIds
43-
* @return ProductInterface[]
44-
*/
45-
private function getCartProduct(array $cartProductsIds): array
46-
{
47-
if (empty($cartProductsIds)) {
48-
return [];
49-
}
50-
/** @var \Magento\Framework\Data\Collection $productCollection */
51-
$productCollection = $this->productCollectionFactory->create()
52-
->addAttributeToSelect('*')
53-
->addIdFilter($cartProductsIds)
54-
->setFlag('has_stock_status_filter', true);
55-
56-
return $productCollection->getItems();
57-
}
58-
5935
/**
6036
* Get visible cart items and product data for cart items
6137
*
@@ -68,9 +44,11 @@ private function getCartProduct(array $cartProductsIds): array
6844
*/
6945
public function execute(Quote $cart, int $pageSize, int $offset, string $orderBy, string $order): array
7046
{
71-
$result = [];
7247
if (!$cart->getId()) {
73-
return $result;
48+
return [
49+
'total' => 0,
50+
'items' => []
51+
];
7452
}
7553
/** @var \Magento\Framework\Data\Collection $itemCollection */
7654
$itemCollection = $this->itemCollectionFactory->create()
@@ -81,20 +59,19 @@ public function execute(Quote $cart, int $pageSize, int $offset, string $orderBy
8159
->setPageSize($pageSize);
8260

8361
$items = [];
84-
$cartProductsIds = [];
8562
$itemDeletedCount = 0;
8663
/** @var \Magento\Quote\Model\Quote\Item $item */
8764
foreach ($itemCollection->getItems() as $item) {
8865
if (!$item->isDeleted()) {
8966
$items[] = $item;
90-
$cartProductsIds[] = $item->getProduct()->getId();
9167
} else {
9268
$itemDeletedCount++;
9369
}
9470
}
95-
$result['total'] = $itemCollection->getSize() - $itemDeletedCount;
96-
$result['items'] = $items;
97-
$result['products'] = $this->getCartProduct($cartProductsIds);
98-
return $result;
71+
72+
return [
73+
'total' => $itemCollection->getSize() - $itemDeletedCount,
74+
'items' => $items
75+
];
9976
}
10077
}

0 commit comments

Comments
 (0)