Skip to content

Commit 1f5d1b4

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into 2.3-develop-pr29
2 parents 702b74f + fb3fb8e commit 1f5d1b4

File tree

16 files changed

+468
-129
lines changed

16 files changed

+468
-129
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Catalog\Model;
710

811
use Magento\Catalog\Api\CategoryListInterface;
@@ -50,7 +53,7 @@ class CategoryList implements CategoryListInterface
5053
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
5154
* @param CategorySearchResultsInterfaceFactory $categorySearchResultsFactory
5255
* @param CategoryRepositoryInterface $categoryRepository
53-
* @param CollectionProcessorInterface $collectionProcessor
56+
* @param CollectionProcessorInterface|null $collectionProcessor
5457
*/
5558
public function __construct(
5659
CollectionFactory $categoryCollectionFactory,
@@ -74,12 +77,13 @@ public function getList(SearchCriteriaInterface $searchCriteria)
7477
/** @var Collection $collection */
7578
$collection = $this->categoryCollectionFactory->create();
7679
$this->extensionAttributesJoinProcessor->process($collection);
77-
7880
$this->collectionProcessor->process($searchCriteria, $collection);
7981

8082
$items = [];
81-
foreach ($collection->getAllIds() as $id) {
82-
$items[] = $this->categoryRepository->get($id);
83+
foreach ($collection->getData() as $categoryData) {
84+
$items[] = $this->categoryRepository->get(
85+
$categoryData[$collection->getEntity()->getIdFieldName()]
86+
);
8387
}
8488

8589
/** @var CategorySearchResultsInterface $searchResult */
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminAddBundleProductToCartFromWishListPageTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Add bundle product to Cart"/>
14+
<title value="Add bundle product to Cart from Wish list page"/>
15+
<description value="Add bundle product to Cart from Wish list page"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-17782"/>
18+
<useCaseId value="MC-17387"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<!-- Login as Admin -->
23+
<comment userInput="Login as Admin" stepKey="commentLoginAsAdmin"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
<!-- Create customer on Storefront and bundle product -->
26+
<comment userInput="Create customer on Storefront and bundle product" stepKey="commentCreateData"/>
27+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
28+
<createData entity="CustomerEntityOne" stepKey="createCustomerViaTheStorefront"/>
29+
<createData entity="_defaultProduct" stepKey="createSimpleProduct1">
30+
<requiredEntity createDataKey="createCategory"/>
31+
</createData>
32+
<createData entity="_defaultProduct" stepKey="createSimpleProduct2">
33+
<requiredEntity createDataKey="createCategory"/>
34+
</createData>
35+
<createData entity="ApiBundleProductPriceViewRange" stepKey="createProduct">
36+
<requiredEntity createDataKey="createCategory"/>
37+
</createData>
38+
<!-- Create Attribute -->
39+
<comment userInput="Create Attribute" stepKey="commentCreateAttribute"/>
40+
<createData entity="DropDownBundleOption" stepKey="bundleOption">
41+
<requiredEntity createDataKey="createProduct"/>
42+
</createData>
43+
<createData entity="ApiBundleLink" stepKey="createBundleLink1">
44+
<requiredEntity createDataKey="createProduct"/>
45+
<requiredEntity createDataKey="bundleOption"/>
46+
<requiredEntity createDataKey="createSimpleProduct1"/>
47+
</createData>
48+
<createData entity="ApiBundleLink" stepKey="createBundleLink2">
49+
<requiredEntity createDataKey="createProduct"/>
50+
<requiredEntity createDataKey="bundleOption"/>
51+
<requiredEntity createDataKey="createSimpleProduct2"/>
52+
</createData>
53+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="goToProductEditPage"/>
54+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
55+
</before>
56+
<after>
57+
<!-- Delete created data -->
58+
<comment userInput="Delete created data" stepKey="commentDeleteCreatedData"/>
59+
<deleteData createDataKey="createCustomerViaTheStorefront" stepKey="deleteCustomerViaTheStorefront"/>
60+
<deleteData createDataKey="createProduct" stepKey="deleteProduct" />
61+
<!-- Log out -->
62+
<comment userInput="Log out" stepKey="commentLogOut"/>
63+
<actionGroup ref="logout" stepKey="logout"/>
64+
</after>
65+
<!-- Login to the Storefront as created customer -->
66+
<comment userInput="Login to the Storefront as created customer" stepKey="commentLoginAsCustomer"/>
67+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
68+
<argument name="Customer" value="$$createCustomerViaTheStorefront$$"/>
69+
</actionGroup>
70+
<!-- Add product to Wish List -->
71+
<comment userInput="Add product to Wish List" stepKey="commentAddProductToWishList"/>
72+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="amOnBundleProductPage"/>
73+
<waitForPageLoad stepKey="waitForProductPage"/>
74+
<actionGroup ref="StorefrontCustomerAddProductToWishlistActionGroup" stepKey="addToWishlistProduct">
75+
<argument name="productVar" value="$$createProduct$$"/>
76+
</actionGroup>
77+
<moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName($$createProduct.name$$)}}" stepKey="moveMouseOverProduct" />
78+
<click selector="{{StorefrontCategoryProductSection.ProductAddToCartByName($$createProduct.name$$)}}" stepKey="clickAddToCart" />
79+
<waitForPageLoad stepKey="waitForProductBundlePage"/>
80+
<!-- See error message -->
81+
<comment userInput="See error message" stepKey="commentSeeErrorMessage"/>
82+
<see userInput=" Please specify product option(s)." stepKey="seeErrorMessage"/>
83+
</test>
84+
</tests>

app/code/Magento/Catalog/Test/Unit/Model/CategoryListTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Catalog\Test\Unit\Model;
710

811
use Magento\Catalog\Api\CategoryRepositoryInterface;
@@ -52,6 +55,9 @@ class CategoryListTest extends \PHPUnit\Framework\TestCase
5255
*/
5356
private $collectionProcessorMock;
5457

58+
/**
59+
* @inheritdoc
60+
*/
5561
protected function setUp()
5662
{
5763
$this->categoryCollectionFactory = $this->getMockBuilder(CollectionFactory::class)
@@ -93,7 +99,12 @@ public function testGetList()
9399

94100
$collection = $this->getMockBuilder(Collection::class)->disableOriginalConstructor()->getMock();
95101
$collection->expects($this->once())->method('getSize')->willReturn($totalCount);
96-
$collection->expects($this->once())->method('getAllIds')->willReturn([$categoryIdFirst, $categoryIdSecond]);
102+
$collection->expects($this->once())->method('getData')->willReturn(
103+
[['entity_id' => $categoryIdFirst], ['entity_id' => $categoryIdSecond]]
104+
);
105+
$collection->expects($this->any())->method('getEntity')->willReturn(
106+
new \Magento\Framework\DataObject(['id_field_name' => 'entity_id'])
107+
);
97108

98109
$this->collectionProcessorMock->expects($this->once())
99110
->method('process')
@@ -106,10 +117,7 @@ public function testGetList()
106117

107118
$this->categoryRepository->expects($this->exactly(2))
108119
->method('get')
109-
->willReturnMap([
110-
[$categoryIdFirst, $categoryFirst],
111-
[$categoryIdSecond, $categorySecond],
112-
])
120+
->willReturnMap([[$categoryIdFirst, $categoryFirst], [$categoryIdSecond, $categorySecond]])
113121
->willReturn($categoryFirst);
114122

115123
$this->categorySearchResultsFactory->expects($this->once())->method('create')->willReturn($searchResult);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="StorefrontCheckProductStockStatus">
12+
<arguments>
13+
<argument name="productUrlKey" type="string"/>
14+
<argument name="productName" type="string"/>
15+
<argument name="stockStatus" type="string" defaultValue="IN STOCK"/>
16+
</arguments>
17+
<amOnPage url="{{StorefrontProductPage.url(productUrlKey)}}" stepKey="navigateToProductPage"/>
18+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
19+
<see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{productName}}" stepKey="seeProductName"/>
20+
<see userInput="{{stockStatus}}" stepKey="assertProductStockStatus"/>
21+
</actionGroup>
22+
</actionGroups>
23+

app/code/Magento/MediaStorage/Console/Command/ImagesResizeCommand.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected function configure()
7676
protected function execute(InputInterface $input, OutputInterface $output)
7777
{
7878
try {
79+
$errors = [];
7980
$this->appState->setAreaCode(Area::AREA_GLOBAL);
8081
$generator = $this->resize->resizeFromThemes();
8182

@@ -95,7 +96,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
9596
}
9697

9798
while ($generator->valid()) {
98-
$progress->setMessage($generator->key());
99+
$resizeInfo = $generator->key();
100+
$error = $resizeInfo['error'];
101+
$filename = $resizeInfo['filename'];
102+
103+
if ($error !== '') {
104+
$errors[$filename] = $error;
105+
}
106+
107+
$progress->setMessage($filename);
99108
$progress->advance();
100109
$generator->next();
101110
}
@@ -106,7 +115,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
106115
}
107116

108117
$output->write(PHP_EOL);
109-
$output->writeln("<info>Product images resized successfully</info>");
118+
if (count($errors)) {
119+
$output->writeln("<info>Product images resized with errors:</info>");
120+
foreach ($errors as $error) {
121+
$output->writeln("<error>{$error}</error>");
122+
}
123+
} else {
124+
$output->writeln("<info>Product images resized successfully</info>");
125+
}
110126

111127
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
112128
}

app/code/Magento/MediaStorage/Service/ImageResize.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,24 @@ public function resizeFromThemes(array $themes = null): \Generator
177177
$viewImages = $this->getViewImages($themes ?? $this->getThemesInUse());
178178

179179
foreach ($productImages as $image) {
180+
$error = '';
180181
$originalImageName = $image['filepath'];
182+
181183
$mediastoragefilename = $this->imageConfig->getMediaPath($originalImageName);
182184
$originalImagePath = $this->mediaDirectory->getAbsolutePath($mediastoragefilename);
183185

184-
foreach ($viewImages as $viewImage) {
185-
if ($this->fileStorageDatabase->checkDbUsage() &&
186-
!$this->mediaDirectory->isFile($mediastoragefilename)
187-
) {
188-
$this->fileStorageDatabase->saveFileToFilesystem($mediastoragefilename);
186+
if ($this->mediaDirectory->isFile($originalImagePath)) {
187+
foreach ($viewImages as $viewImage) {
188+
if ($this->fileStorageDatabase->checkDbUsage()) {
189+
$this->fileStorageDatabase->saveFileToFilesystem($mediastoragefilename);
190+
}
191+
$this->resize($viewImage, $originalImagePath, $originalImageName);
189192
}
190-
$this->resize($viewImage, $originalImagePath, $originalImageName);
193+
} else {
194+
$error = __('Cannot resize image "%1" - original image not found', $originalImagePath);
191195
}
192-
yield $originalImageName => $count;
196+
197+
yield ['filename' => $originalImageName, 'error' => $error] => $count;
193198
}
194199
}
195200

app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function () {
248248
$this->mediaDirectoryMock->expects($this->any())
249249
->method('isFile')
250250
->with($this->testfilepath)
251-
->will($this->returnValue(false));
251+
->will($this->returnValue(true));
252252

253253
$this->databaseMock->expects($this->once())
254254
->method('saveFileToFilesystem')
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="SimpleProductPrice10Qty1" type="product">
12+
<data key="sku" unique="suffix">simple-product_</data>
13+
<data key="type_id">simple</data>
14+
<data key="attribute_set_id">4</data>
15+
<data key="visibility">4</data>
16+
<data key="name" unique="suffix">SimpleProduct_</data>
17+
<data key="price">10.00</data>
18+
<data key="urlKey" unique="suffix">simple-product_</data>
19+
<data key="status">1</data>
20+
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
21+
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
22+
</entity>
23+
<entity name="VirtualProductPrice10Qty1" type="product">
24+
<data key="sku" unique="suffix">virtual-product_</data>
25+
<data key="type_id">virtual</data>
26+
<data key="attribute_set_id">4</data>
27+
<data key="name" unique="suffix">VirtualProduct_</data>
28+
<data key="price">10.00</data>
29+
<data key="weight">0</data>
30+
<data key="status">1</data>
31+
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
32+
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
33+
</entity>
34+
<entity name="SimpleProduct2Price10Qty1" type="product">
35+
<data key="sku" unique="suffix">simple-product-2_</data>
36+
<data key="type_id">simple</data>
37+
<data key="attribute_set_id">4</data>
38+
<data key="name" unique="suffix">SimpleProduct2_</data>
39+
<data key="price">10.00</data>
40+
<data key="visibility">4</data>
41+
<data key="status">1</data>
42+
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
43+
</entity>
44+
<entity name="SimpleProduct3Price10Qty1" type="product2">
45+
<data key="sku" unique="suffix">simple-product-3_</data>
46+
<data key="type_id">simple</data>
47+
<data key="attribute_set_id">4</data>
48+
<data key="visibility">4</data>
49+
<data key="name" unique="suffix">SimpleProduct3_</data>
50+
<data key="price">10.00</data>
51+
<data key="urlKey" unique="suffix">simple-product-3_</data>
52+
<data key="status">1</data>
53+
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
54+
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
55+
</entity>
56+
<entity name="ConfigurableProductPrice10Qty1" type="product">
57+
<data key="sku" unique="suffix">configurable-product_</data>
58+
<data key="type_id">configurable</data>
59+
<data key="attribute_set_id">4</data>
60+
<data key="visibility">4</data>
61+
<data key="name" unique="suffix">ConfigurableProduct_</data>
62+
<data key="urlKey" unique="suffix">configurable-product_</data>
63+
<data key="price">10.00</data>
64+
<data key="weight">2</data>
65+
<data key="status">1</data>
66+
<data key="quantity">1</data>
67+
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
68+
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
69+
</entity>
70+
</entities>

0 commit comments

Comments
 (0)