Skip to content

Commit 5ffb6a6

Browse files
author
OlgaVasyltsun
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-35891
2 parents 5dbcd2c + 2841088 commit 5ffb6a6

File tree

76 files changed

+1993
-125
lines changed

Some content is hidden

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

76 files changed

+1993
-125
lines changed

app/code/Magento/AsynchronousOperations/Model/MassConsumer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ public function process($maxNumberOfMessages = null)
6969
$this->registry->register('isSecureArea', true, true);
7070

7171
$queue = $this->configuration->getQueue();
72+
$maxIdleTime = $this->configuration->getMaxIdleTime();
73+
$sleep = $this->configuration->getSleep();
7274

7375
if (!isset($maxNumberOfMessages)) {
7476
$queue->subscribe($this->getTransactionCallback($queue));
7577
} else {
76-
$this->invoker->invoke($queue, $maxNumberOfMessages, $this->getTransactionCallback($queue));
78+
$this->invoker->invoke(
79+
$queue,
80+
$maxNumberOfMessages,
81+
$this->getTransactionCallback($queue),
82+
$maxIdleTime,
83+
$sleep
84+
);
7785
}
7886

7987
$this->registry->unregister('isSecureArea');

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
8787
*
8888
* @var string
8989
*/
90-
protected $_cacheTag = self::CACHE_TAG;
90+
protected $_cacheTag = false;
9191

9292
/**
9393
* URL Model instance
@@ -1111,6 +1111,17 @@ public function afterSave()
11111111
return $result;
11121112
}
11131113

1114+
/**
1115+
* @inheritDoc
1116+
*/
1117+
public function getCacheTags()
1118+
{
1119+
$identities = $this->getIdentities();
1120+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
1121+
1122+
return $cacheTags;
1123+
}
1124+
11141125
/**
11151126
* Init indexing process after category save
11161127
*

app/code/Magento/Catalog/Model/Product.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
1212
use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
1313
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
14-
use Magento\Catalog\Model\FilterProductCustomAttribute;
1514
use Magento\Framework\Api\AttributeValueFactory;
1615
use Magento\Framework\App\Filesystem\DirectoryList;
1716
use Magento\Framework\App\ObjectManager;
@@ -977,6 +976,17 @@ public function afterSave()
977976
return $result;
978977
}
979978

979+
/**
980+
* @inheritDoc
981+
*/
982+
public function getCacheTags()
983+
{
984+
$identities = $this->getIdentities();
985+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
986+
987+
return $cacheTags;
988+
}
989+
980990
/**
981991
* Set quantity for product
982992
*
@@ -2158,7 +2168,7 @@ public function reset()
21582168
*/
21592169
public function getCacheIdTags()
21602170
{
2161-
// phpstan:ignore
2171+
// phpstan:ignore "Call to an undefined static method"
21622172
$tags = parent::getCacheIdTags();
21632173
$affectedCategoryIds = $this->getAffectedCategoryIds();
21642174
if (!$affectedCategoryIds) {
@@ -2339,7 +2349,8 @@ public function isDisabled()
23392349
public function getImage()
23402350
{
23412351
$this->getTypeInstance()->setImageFromChildProduct($this);
2342-
// phpstan:ignore
2352+
2353+
// phpstan:ignore "Call to an undefined static method"
23432354
return parent::getImage();
23442355
}
23452356

@@ -2403,6 +2414,8 @@ public function reloadPriceInfo()
24032414
}
24042415
}
24052416

2417+
//phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2418+
24062419
/**
24072420
* Return Data Object data in array format.
24082421
*
@@ -2430,6 +2443,8 @@ public function __toArray() //phpcs:ignore PHPCompatibility.FunctionNameRestrict
24302443
return $data;
24312444
}
24322445

2446+
//phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2447+
24332448
/**
24342449
* Convert Category model into flat array.
24352450
*
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\Model;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\PageCache\Model\Spi\PageCacheTagsPreprocessorInterface;
14+
use Magento\Store\Model\StoreManagerInterface;
15+
16+
/**
17+
* Add product identities to "noroute" page
18+
*
19+
* Ensure that "noroute" page has necessary product tags
20+
* so it can be invalidated once the product becomes visible again
21+
*/
22+
class ProductNotFoundPageCacheTags implements PageCacheTagsPreprocessorInterface
23+
{
24+
private const NOROUTE_ACTION_NAME = 'cms_noroute_index';
25+
/**
26+
* @var ProductRepositoryInterface
27+
*/
28+
private $productRepository;
29+
/**
30+
* @var StoreManagerInterface
31+
*/
32+
private $storeManager;
33+
/**
34+
* @var RequestInterface
35+
*/
36+
private $request;
37+
38+
/**
39+
* @param RequestInterface $request
40+
* @param ProductRepositoryInterface $productRepository
41+
* @param StoreManagerInterface $storeManager
42+
*/
43+
public function __construct(
44+
RequestInterface $request,
45+
ProductRepositoryInterface $productRepository,
46+
StoreManagerInterface $storeManager
47+
) {
48+
$this->productRepository = $productRepository;
49+
$this->storeManager = $storeManager;
50+
$this->request = $request;
51+
}
52+
53+
/**
54+
* @inheritDoc
55+
*/
56+
public function process(array $tags): array
57+
{
58+
if ($this->request->getFullActionName() === self::NOROUTE_ACTION_NAME) {
59+
try {
60+
$productId = (int) $this->request->getParam('id');
61+
$product = $this->productRepository->getById(
62+
$productId,
63+
false,
64+
$this->storeManager->getStore()->getId()
65+
);
66+
} catch (NoSuchEntityException $e) {
67+
$product = null;
68+
}
69+
if ($product) {
70+
$tags = array_merge($tags, $product->getIdentities());
71+
}
72+
}
73+
return $tags;
74+
}
75+
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAndSwitchProductType/AdminCreateSimpleProductSwitchToVirtualTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="searchForProduct">
5555
<argument name="product" value="_defaultProduct"/>
5656
</actionGroup>
57-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Virtual Product" stepKey="seeProductTypeInGrid"/>
57+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductTypeInGrid">
58+
<argument name="row" value="1"/>
59+
<argument name="column" value="Type"/>
60+
<argument name="value" value="Virtual Product"/>
61+
</actionGroup>
5862
<actionGroup ref="AssertProductInStorefrontProductPageActionGroup" stepKey="AssertProductInStorefrontProductPage">
5963
<argument name="product" value="_defaultProduct"/>
6064
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAndSwitchProductType/AdminCreateVirtualProductSwitchToSimpleTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<actionGroup ref="FillMainProductFormActionGroup" stepKey="fillProductForm">
2626
<argument name="product" value="_defaultProduct"/>
2727
</actionGroup>
28-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeProductTypeInGrid"/>
28+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductTypeInGrid">
29+
<argument name="row" value="1"/>
30+
<argument name="column" value="Type"/>
31+
<argument name="value" value="Simple Product"/>
32+
</actionGroup>
2933
</test>
3034
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest/AdminDownloadableProductTypeSwitchingToSimpleProductTest.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@
3333
<actionGroup ref="FilterProductGridBySku2ActionGroup" stepKey="filterSimpleProductGridBySku">
3434
<argument name="sku" value="$$createProduct.sku$$"/>
3535
</actionGroup>
36-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeSimpleProductNameInGrid"/>
37-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeSimpleProductTypeInGrid"/>
36+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeSimpleProductNameInGrid">
37+
<argument name="row" value="1"/>
38+
<argument name="column" value="Name"/>
39+
<argument name="value" value="$$createProduct.name$$"/>
40+
</actionGroup>
41+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeSimpleProductTypeInGrid">
42+
<argument name="row" value="1"/>
43+
<argument name="column" value="Type"/>
44+
<argument name="value" value="Simple Product"/>
45+
</actionGroup>
3846
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearSimpleProductFilters"/>
3947
<!--Assert simple product on storefront-->
4048
<comment userInput="Assert simple product on storefront" stepKey="commentAssertSimpleProductOnStorefront"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest/AdminVirtualProductTypeSwitchingToDownloadableProductTest.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@
5353
<actionGroup ref="FilterProductGridBySku2ActionGroup" stepKey="filterProductGridBySku">
5454
<argument name="sku" value="$$createProduct.sku$$"/>
5555
</actionGroup>
56-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeDownloadableProductNameInGrid"/>
57-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Downloadable Product" stepKey="seeDownloadableProductTypeInGrid"/>
56+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeDownloadableProductNameInGrid">
57+
<argument name="row" value="1"/>
58+
<argument name="column" value="Name"/>
59+
<argument name="value" value="$$createProduct.name$$"/>
60+
</actionGroup>
61+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeDownloadableProductTypeInGrid">
62+
<argument name="row" value="1"/>
63+
<argument name="column" value="Type"/>
64+
<argument name="value" value="Downloadable Product"/>
65+
</actionGroup>
5866
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearDownloadableProductFilters"/>
5967
<!--Assert downloadable product on storefront-->
6068
<comment userInput="Assert downloadable product on storefront" stepKey="commentAssertDownloadableProductOnStorefront"/>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
<argument name="keyword" value="SimpleProduct.name"/>
8080
</actionGroup>
8181
<seeNumberOfElements selector="{{AdminProductGridSection.productGridRows}}" userInput="1" stepKey="seeOnlyOneProductInGrid"/>
82-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="{{SimpleProduct.name}}" stepKey="seeOnlySimpleProductInGrid"/>
82+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeOnlySimpleProductInGrid">
83+
<argument name="row" value="1"/>
84+
<argument name="column" value="Name"/>
85+
<argument name="value" value="{{SimpleProduct.name}}"/>
86+
</actionGroup>
8387

8488
<!--Paging works-->
8589
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="setProductGridToDefaultPagination"/>
@@ -105,7 +109,11 @@
105109
<argument name="product" value="GroupedProduct"/>
106110
</actionGroup>
107111
<seeNumberOfElements selector="{{AdminProductGridSection.productGridRows}}" userInput="1" stepKey="seeOneMatchingSkuInProductGrid"/>
108-
<see selector="{{AdminProductGridSection.productGridCell('1','SKU')}}" userInput="{{GroupedProduct.sku}}" stepKey="seeProductInFilteredGridSku"/>
112+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductInFilteredGridSku">
113+
<argument name="row" value="1"/>
114+
<argument name="column" value="SKU"/>
115+
<argument name="value" value="{{GroupedProduct.sku}}"/>
116+
</actionGroup>
109117
<!--Filter by price-->
110118
<actionGroup ref="FilterProductGridByPriceRangeActionGroup" stepKey="filterProductGridByPrice">
111119
<argument name="filter" value="PriceFilterRange"/>
@@ -194,7 +202,11 @@
194202
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterProductGridToCheckWeightColumn">
195203
<argument name="product" value="SimpleProduct"/>
196204
</actionGroup>
197-
<see selector="{{AdminProductGridSection.productGridCell('1','Weight')}}" userInput="{{SimpleProduct.weight}}" stepKey="seeCorrectProductWeightInGrid"/>
205+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeCorrectProductWeightInGrid">
206+
<argument name="row" value="1"/>
207+
<argument name="column" value="Weight"/>
208+
<argument name="value" value="{{SimpleProduct.weight}}"/>
209+
</actionGroup>
198210
<!--END Admin uses product grid-->
199211

200212
<!--Admin creates category-->

app/code/Magento/Catalog/etc/frontend/di.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
</argument>
1414
</arguments>
1515
</virtualType>
16-
<type name="Magento\Catalog\Model\ResourceModel\Category\Collection">
17-
<arguments>
18-
<argument name="fetchStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Category\Collection\FetchStrategy</argument>
19-
</arguments>
20-
</type>
2116
<type name="Magento\Catalog\Model\Indexer\AbstractFlatState">
2217
<arguments>
2318
<argument name="isAvailable" xsi:type="boolean">true</argument>
@@ -120,4 +115,13 @@
120115
<plugin name="catalog_app_action_dispatch_controller_context_plugin"
121116
type="Magento\Catalog\Plugin\Framework\App\Action\ContextPlugin" />
122117
</type>
118+
<type name="\Magento\PageCache\Model\PageCacheTagsPreprocessorComposite">
119+
<arguments>
120+
<argument name="preprocessors" xsi:type="array">
121+
<item name="catalog_product_view" xsi:type="array">
122+
<item name="product_not_found" xsi:type="object">Magento\Catalog\Model\ProductNotFoundPageCacheTags</item>
123+
</item>
124+
</argument>
125+
</arguments>
126+
</type>
123127
</config>

0 commit comments

Comments
 (0)