Skip to content

Commit 57a6a4b

Browse files
authored
Merge branch '2.4-develop' into 825-adobestock-remove-directory
2 parents c24206e + 06a0dd0 commit 57a6a4b

File tree

65 files changed

+1928
-866
lines changed

Some content is hidden

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

65 files changed

+1928
-866
lines changed

app/code/Magento/Catalog/Controller/Product/Compare/Index.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\View\Result\PageFactory;
1313

1414
/**
15+
* View products compare in frontend
16+
*
1517
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1618
*/
1719
class Index extends \Magento\Catalog\Controller\Product\Compare implements HttpGetActionInterface
@@ -74,23 +76,12 @@ public function __construct(
7476
*/
7577
public function execute()
7678
{
77-
$items = $this->getRequest()->getParam('items');
78-
7979
$beforeUrl = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED);
8080
if ($beforeUrl) {
8181
$this->_catalogSession->setBeforeCompareUrl(
8282
$this->urlDecoder->decode($beforeUrl)
8383
);
8484
}
85-
86-
if ($items) {
87-
$items = explode(',', $items);
88-
/** @var \Magento\Catalog\Model\Product\Compare\ListCompare $list */
89-
$list = $this->_catalogProductCompareList;
90-
$list->addProducts($items);
91-
$resultRedirect = $this->resultRedirectFactory->create();
92-
return $resultRedirect->setPath('*/*/*');
93-
}
9485
return $this->resultPageFactory->create();
9586
}
9687
}

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @api
1515
* @SuppressWarnings(PHPMD.LongVariable)
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1718
* @since 100.0.2
1819
*/
1920
class Compare extends \Magento\Framework\Url\Helper\Data
@@ -145,16 +146,9 @@ public function __construct(
145146
*/
146147
public function getListUrl()
147148
{
148-
$itemIds = [];
149-
foreach ($this->getItemCollection() as $item) {
150-
$itemIds[] = $item->getId();
151-
}
152-
153149
$params = [
154-
'items' => implode(',', $itemIds),
155150
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
156151
];
157-
158152
return $this->_getUrl('catalog/product_compare', $params);
159153
}
160154

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,4 @@
2525
<checkOption selector="{{AdminProductImagesSection.roleSwatch}}" stepKey="checkRoleSwatch"/>
2626
<click selector="{{AdminSlideOutDialogSection.closeButton}}" stepKey="clickCloseButton"/>
2727
</actionGroup>
28-
<actionGroup name="AdminAssignImageRolesIfUnassignedActionGroup" extends="AdminAssignImageRolesActionGroup">
29-
<annotations>
30-
<description>Requires the navigation to the Product Creation page. Assign the Base, Small, Thumbnail, and Swatch Roles to image.</description>
31-
</annotations>
32-
33-
<conditionalClick selector="{{AdminProductImagesSection.roleBase}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Base')}}" visible="false" stepKey="checkRoleBase"/>
34-
<conditionalClick selector="{{AdminProductImagesSection.roleSmall}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Small')}}" visible="false" stepKey="checkRoleSmall"/>
35-
<conditionalClick selector="{{AdminProductImagesSection.roleThumbnail}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Thumbnail')}}" visible="false" stepKey="checkRoleThumbnail"/>
36-
<conditionalClick selector="{{AdminProductImagesSection.roleSwatch}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Swatch')}}" visible="false" stepKey="checkRoleSwatch"/>
37-
</actionGroup>
3828
</actionGroups>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminAssignImageRolesIfUnassignedActionGroup" extends="AdminAssignImageRolesActionGroup">
12+
<annotations>
13+
<description>Requires the navigation to the Product Creation page. Assign the Base, Small, Thumbnail, and Swatch Roles to image.</description>
14+
</annotations>
15+
16+
<conditionalClick selector="{{AdminProductImagesSection.roleBase}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Base')}}" visible="false" stepKey="checkRoleBase"/>
17+
<conditionalClick selector="{{AdminProductImagesSection.roleSmall}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Small')}}" visible="false" stepKey="checkRoleSmall"/>
18+
<conditionalClick selector="{{AdminProductImagesSection.roleThumbnail}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Thumbnail')}}" visible="false" stepKey="checkRoleThumbnail"/>
19+
<conditionalClick selector="{{AdminProductImagesSection.roleSwatch}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Swatch')}}" visible="false" stepKey="checkRoleSwatch"/>
20+
</actionGroup>
21+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/DeleteProductActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
<waitForPageLoad stepKey="waitForDeleteItemPopup" time="10"/>
2828
<click stepKey="clickOnOk" selector="{{ProductsPageSection.ok}}"/>
2929
<waitForElementVisible stepKey="waitForSuccessfullyDeletedMessage" selector="{{ProductsPageSection.deletedSuccessMessage}}" time="10"/>
30+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear"/>
3031
</actionGroup>
3132
</actionGroups>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<waitForPageLoad stepKey="waitForSimpleProductPageLoad"/>
3939
<!--Save and duplicated the product once-->
4040
<comment userInput="Save and duplicated the product once" stepKey="commentSaveAndDuplicateProduct"/>
41-
<actionGroup ref="AdminFormSaveAndDuplicate" stepKey="saveAndDuplicateProductFormFirstTime"/>
41+
<actionGroup ref="AdminFormSaveAndDuplicateActionGroup" stepKey="saveAndDuplicateProductFormFirstTime"/>
4242
<conditionalClick selector="{{AdminProductSEOSection.sectionHeader}}" dependentSelector="{{AdminProductSEOSection.urlKeyInput}}" visible="false" stepKey="openSEOSection"/>
4343
<grabValueFrom selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="grabDuplicatedProductUrlKey"/>
4444
<assertContains expected="$$createSimpleProduct.custom_attributes[url_key]$$" actual="$grabDuplicatedProductUrlKey" stepKey="assertDuplicatedProductUrlKey"/>
@@ -65,7 +65,7 @@
6565
<comment userInput="Save and duplicated the product second time" stepKey="commentSaveAndDuplicateProduct1"/>
6666
<amOnPage url="{{AdminProductEditPage.url($$createSimpleProduct.id$$)}}" stepKey="goToProductEditPage1"/>
6767
<waitForPageLoad stepKey="waitForSimpleProductPageLoad2"/>
68-
<actionGroup ref="AdminFormSaveAndDuplicate" stepKey="saveAndDuplicateProductFormSecondTime"/>
68+
<actionGroup ref="AdminFormSaveAndDuplicateActionGroup" stepKey="saveAndDuplicateProductFormSecondTime"/>
6969
<conditionalClick selector="{{AdminProductSEOSection.sectionHeader}}" dependentSelector="{{AdminProductSEOSection.urlKeyInput}}" visible="false" stepKey="openProductSEOSection"/>
7070
<waitForElementVisible selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="waitForUrlKeyField"/>
7171
<grabValueFrom selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="grabSecondDuplicatedProductUrlKey"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@
7272
<argument name="product" value="$$createSimpleProduct$$"/>
7373
</actionGroup>
7474
<!--Save and duplicated the product once-->
75-
<actionGroup ref="AdminFormSaveAndDuplicate" stepKey="saveAndDuplicateProductForm1"/>
75+
<actionGroup ref="AdminFormSaveAndDuplicateActionGroup" stepKey="saveAndDuplicateProductForm1"/>
7676
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct2">
7777
<argument name="product" value="$$createSimpleProduct$$"/>
7878
</actionGroup>
7979
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct2">
8080
<argument name="product" value="$$createSimpleProduct$$"/>
8181
</actionGroup>
8282
<!--Save and duplicated the product second time-->
83-
<actionGroup ref="AdminFormSaveAndDuplicate" stepKey="saveAndDuplicateProductForm2"/>
83+
<actionGroup ref="AdminFormSaveAndDuplicateActionGroup" stepKey="saveAndDuplicateProductForm2"/>
8484
</test>
8585
</tests>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct2">
6262
<argument name="product" value="$$product2$$"/>
6363
</actionGroup>
64-
<actionGroup ref="AdminFormSaveAndClose" stepKey="saveAndCloseProduct"/>
64+
<actionGroup ref="AdminFormSaveAndCloseActionGroup" stepKey="saveAndCloseProduct"/>
6565
<waitForPageLoad stepKey="waitForPageLoad1"/>
6666
<seeInField selector="{{AdminDataGridPaginationSection.currentPage}}" userInput="2" stepKey="seeOnSecondPageOrderGrid"/>
6767
</test>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<createData entity="_defaultProduct" stepKey="productTwo">
3030
<requiredEntity createDataKey="simpleSubCategoryOne"/>
3131
</createData>
32+
<magentoCLI command="cron:run --group=index" stepKey="runIndexerCron"/>
3233
</before>
3334
<after>
3435
<actionGroup ref="logout" stepKey="logoutAdminUserAfterTest"/>
@@ -119,4 +120,4 @@
119120
<see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$$simpleSubCategoryOne.name$$" stepKey="seeSubCategoryWithParentInBreadcrumbsOnSubCategoryWithParent3"/>
120121
<see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$$productOne.name$$" stepKey="seeProductInBreadcrumbsOnSubCategoryOne3"/>
121122
</test>
122-
</tests>
123+
</tests>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<actionGroup ref="FilterProductGridBySetNewFromDateActionGroup" stepKey="filterProductGridToCheckSetAsNewColumn"/>
4949
<click selector="{{AdminProductGridSection.firstRow}}" stepKey="clickOnFirstRowProductGrid"/>
5050
<waitForPageLoad stepKey="waitForProductEditPageToLoad"/>
51-
<actionGroup ref="AdminFormSaveAndClose" stepKey="saveAndCloseProductForm"/>
51+
<actionGroup ref="AdminFormSaveAndCloseActionGroup" stepKey="saveAndCloseProductForm"/>
5252
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="expandFilters"/>
5353
<seeInField selector="{{AdminProductGridFilterSection.newFromDateFilter}}" userInput="05/16/2018" stepKey="checkForNewFromDate"/>
5454
<click selector="{{AdminProductGridFilterSection.columnsDropdown}}" stepKey="openColumnsDropdown2"/>

app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public function testExecute()
129129
->method('getParam')
130130
->willReturnMap(
131131
[
132-
['items', null, null],
133132
['uenc', null, $beforeUrl],
134133
]
135134
);
@@ -141,34 +140,7 @@ public function testExecute()
141140
->method('setBeforeCompareUrl')
142141
->with($beforeUrl . '1')
143142
->willReturnSelf();
144-
$this->listCompareMock->expects($this->never())->method('addProducts');
145143
$this->redirectFactoryMock->expects($this->never())->method('create');
146144
$this->index->execute();
147145
}
148-
149-
public function testExecuteWithItems()
150-
{
151-
$this->request->expects($this->any())
152-
->method('getParam')
153-
->willReturnMap(
154-
[
155-
['items', null, '1,2,3'],
156-
['uenc', null, null],
157-
]
158-
);
159-
$this->decoderMock->expects($this->never())->method('decode');
160-
$this->catalogSession->expects($this->never())->method('setBeforeCompareUrl');
161-
162-
$this->listCompareMock->expects($this->once())
163-
->method('addProducts')
164-
->with([1, 2, 3]);
165-
$redirect = $this->createPartialMock(\Magento\Framework\Controller\Result\Redirect::class, ['setPath']);
166-
$redirect->expects($this->once())
167-
->method('setPath')
168-
->with('*/*/*');
169-
$this->redirectFactoryMock->expects($this->once())
170-
->method('create')
171-
->willReturn($redirect);
172-
$this->index->execute();
173-
}
174146
}

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Export;
77

8+
use Magento\Catalog\Model\Product as ProductEntity;
89
use Magento\Catalog\Model\ResourceModel\Product\Option\Collection;
10+
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
911
use Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor;
12+
use Magento\Framework\App\ObjectManager;
1013
use Magento\ImportExport\Model\Import;
11-
use \Magento\Store\Model\Store;
12-
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
13-
use Magento\Catalog\Model\Product as ProductEntity;
14+
use Magento\Store\Model\Store;
1415

1516
/**
1617
* Export entity product model
@@ -21,6 +22,8 @@
2122
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2223
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2324
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
25+
* @SuppressWarnings(PHPMD.ExcessiveClassLength)
26+
* @SuppressWarnings(PHPMD.TooManyMethods)
2427
* @since 100.0.2
2528
*/
2629
class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
@@ -348,6 +351,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
348351
* @var string
349352
*/
350353
private $productEntityLinkField;
354+
/**
355+
* @var ProductFilterInterface
356+
*/
357+
private $filter;
351358

352359
/**
353360
* Product constructor.
@@ -369,6 +376,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
369376
* @param ProductEntity\LinkTypeProvider $linkTypeProvider
370377
* @param RowCustomizerInterface $rowCustomizer
371378
* @param array $dateAttrCodes
379+
* @param ProductFilterInterface $filter
372380
* @throws \Magento\Framework\Exception\LocalizedException
373381
*/
374382
public function __construct(
@@ -388,7 +396,8 @@ public function __construct(
388396
\Magento\CatalogImportExport\Model\Export\Product\Type\Factory $_typeFactory,
389397
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider,
390398
\Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer,
391-
array $dateAttrCodes = []
399+
array $dateAttrCodes = [],
400+
?ProductFilterInterface $filter = null
392401
) {
393402
$this->_entityCollectionFactory = $collectionFactory;
394403
$this->_exportConfig = $exportConfig;
@@ -404,6 +413,7 @@ public function __construct(
404413
$this->_linkTypeProvider = $linkTypeProvider;
405414
$this->rowCustomizer = $rowCustomizer;
406415
$this->dateAttrCodes = array_merge($this->dateAttrCodes, $dateAttrCodes);
416+
$this->filter = $filter ?? ObjectManager::getInstance()->get(ProductFilterInterface::class);
407417

408418
parent::__construct($localeDate, $config, $resource, $storeManager);
409419

@@ -819,9 +829,11 @@ protected function getItemsPerPage()
819829
case 'g':
820830
$memoryLimit *= 1024;
821831
// fall-through intentional
832+
// no break
822833
case 'm':
823834
$memoryLimit *= 1024;
824835
// fall-through intentional
836+
// no break
825837
case 'k':
826838
$memoryLimit *= 1024;
827839
break;
@@ -913,12 +925,7 @@ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection
913925
$exportFilter = !empty($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP]) ?
914926
$this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP] : [];
915927

916-
if (isset($exportFilter['category_ids'])
917-
&& trim($exportFilter['category_ids'])
918-
&& $collection instanceof \Magento\Catalog\Model\ResourceModel\Product\Collection
919-
) {
920-
$collection->addCategoriesFilter(['in' => explode(',', $exportFilter['category_ids'])]);
921-
}
928+
$collection = $this->filter->filter($collection, $exportFilter);
922929

923930
return parent::_prepareEntityCollection($collection);
924931
}
@@ -979,7 +986,6 @@ protected function loadCollection(): array
979986
$collection = $this->_getEntityCollection();
980987
foreach (array_keys($this->_storeIdToCode) as $storeId) {
981988
$collection->setOrder('entity_id', 'asc');
982-
$this->_prepareEntityCollection($collection);
983989
$collection->setStoreId($storeId);
984990
$collection->load();
985991
foreach ($collection as $itemId => $item) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\CatalogImportExport\Model\Export\Product;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\CatalogImportExport\Model\Export\ProductFilterInterface;
12+
13+
/**
14+
* Category filter for products export
15+
*/
16+
class CategoryFilter implements ProductFilterInterface
17+
{
18+
private const NAME = 'category_ids';
19+
20+
/**
21+
* @inheritDoc
22+
*/
23+
public function filter(Collection $collection, array $filters): Collection
24+
{
25+
$value = trim($filters[self::NAME] ?? '');
26+
if ($value) {
27+
$collection->addCategoriesFilter(['in' => explode(',', $value)]);
28+
}
29+
return $collection;
30+
}
31+
}

0 commit comments

Comments
 (0)