Skip to content

Commit e123f7e

Browse files
committed
Merge remote-tracking branch 'upstream/2.4-develop' into B2B-2257
2 parents cd6574e + 4c54d2b commit e123f7e

File tree

13 files changed

+549
-187
lines changed

13 files changed

+549
-187
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ImageData.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
<data key="filename">jpg</data>
4444
<data key="file_extension">jpg</data>
4545
</entity>
46+
<entity name="GifImageWithUnusedTransparencyIndex" type="image">
47+
<data key="title" unique="suffix">GifImageWithUnusedTransparencyIndex</data>
48+
<data key="file">transparency_index.gif</data>
49+
<data key="filename">transparency_index</data>
50+
<data key="file_extension">gif</data>
51+
</entity>
4652
<entity name="LargeImage" type="image">
4753
<data key="title" unique="suffix">largeimage</data>
4854
<data key="file">large.jpg</data>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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="AdminSimpleProductGifWithUnusedTransparencyImageTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Using a GIF image with transparency color declared but not used as a product main image should not prevent the product grid from being rendered properly"/>
14+
<title value="Using a GIF image with transparency color declared but not used as a product image"/>
15+
<description value="Using a GIF image with transparency color declared but not used as a product main image should not prevent the product grid from being rendered properly"/>
16+
<severity value="CRITICAL"/>
17+
<useCaseId value="ACP2E-1632"/>
18+
<testCaseId value="AC-8028"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="category"/>
24+
<createData entity="_defaultProduct" stepKey="firstProduct">
25+
<requiredEntity createDataKey="category"/>
26+
</createData>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
28+
</before>
29+
30+
<after>
31+
<deleteData createDataKey="category" stepKey="deletePreReqCategory"/>
32+
<deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/>
33+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
34+
</after>
35+
36+
<!-- Navigate to the product grid and edit the product -->
37+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductIndex"/>
38+
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterProductGridBySku">
39+
<argument name="product" value="$$firstProduct$$"/>
40+
</actionGroup>
41+
<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="openProducForEditByClickingRow1Column2InProductGrid"/>
42+
43+
<!-- Set the test GIF image as a main product image and save the product -->
44+
<actionGroup ref="AddProductImageActionGroup" stepKey="addImageForProduct">
45+
<argument name="image" value="GifImageWithUnusedTransparencyIndex"/>
46+
</actionGroup>
47+
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="saveProduct"/>
48+
49+
<!-- Go back to the product grid and make sure the product is present and visible on the grid -->
50+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="returnToProductIndex"/>
51+
<actionGroup ref="AssertProductOnAdminGridActionGroup" stepKey="assertFirstOnAdminGrid">
52+
<argument name="product" value="_defaultProduct"/>
53+
</actionGroup>
54+
55+
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="resetProductGridBeforeLeaving"/>
56+
</test>
57+
</tests>

app/code/Magento/CatalogGraphQl/Model/Resolver/Categories.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
class Categories implements ResolverInterface
2828
{
2929
/**
30-
* @var Collection
30+
* @var CollectionFactory
3131
*/
32-
private $collection;
32+
private $collectionFactory;
3333

3434
/**
3535
* Accumulated category ids
@@ -68,6 +68,11 @@ class Categories implements ResolverInterface
6868
*/
6969
private $storeManager;
7070

71+
/**
72+
* @var array
73+
*/
74+
private $collections = [];
75+
7176
/**
7277
* @param CollectionFactory $collectionFactory
7378
* @param AttributesJoiner $attributesJoiner
@@ -86,7 +91,7 @@ public function __construct(
8691
ProductCategories $productCategories,
8792
StoreManagerInterface $storeManager
8893
) {
89-
$this->collection = $collectionFactory->create();
94+
$this->collectionFactory = $collectionFactory;
9095
$this->attributesJoiner = $attributesJoiner;
9196
$this->customAttributesFlattener = $customAttributesFlattener;
9297
$this->valueFactory = $valueFactory;
@@ -120,12 +125,9 @@ function () use ($that, $categoryIds, $info) {
120125
return [];
121126
}
122127

123-
if (!$this->collection->isLoaded()) {
124-
$that->attributesJoiner->join($info->fieldNodes[0], $this->collection, $info);
125-
$this->collection->addIdFilter($this->categoryIds);
126-
}
128+
$collection = $this->getCollection($that, $info);
127129
/** @var CategoryInterface | \Magento\Catalog\Model\Category $item */
128-
foreach ($this->collection as $item) {
130+
foreach ($collection as $item) {
129131
if (in_array($item->getId(), $categoryIds)) {
130132
// Try to extract all requested fields from the loaded collection data
131133
$categories[$item->getId()] = $this->categoryHydrator->hydrateCategory($item, true);
@@ -146,4 +148,25 @@ function () use ($that, $categoryIds, $info) {
146148
}
147149
);
148150
}
151+
152+
/**
153+
* Returns category collection.
154+
*
155+
* @param Categories $that
156+
* @param ResolveInfo $info
157+
* @return Collection
158+
*/
159+
private function getCollection(Categories $that, ResolveInfo $info): Collection
160+
{
161+
$requestedFields = $that->attributesJoiner->getQueryFields($info->fieldNodes[0], $info);
162+
sort($requestedFields);
163+
$requestedFieldsHash = sha1(implode(',', $requestedFields));
164+
if (!isset($this->collections[$requestedFieldsHash])) {
165+
$this->collections[$requestedFieldsHash] = $this->collectionFactory->create();
166+
$that->attributesJoiner->join($info->fieldNodes[0], $this->collections[$requestedFieldsHash], $info);
167+
$this->collections[$requestedFieldsHash]->addIdFilter($this->categoryIds);
168+
}
169+
170+
return $this->collections[$requestedFieldsHash];
171+
}
149172
}

app/code/Magento/ProductAlert/Model/Mailing/AlertProcessor.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\ProductAlert\Model\Mailing;
99

10-
use Magento\Framework\App\Area;
1110
use Magento\Catalog\Api\Data\ProductInterface;
1211
use Magento\Catalog\Api\ProductRepositoryInterface;
1312
use Magento\Catalog\Helper\Data;
@@ -25,15 +24,11 @@
2524
use Magento\Store\Api\Data\WebsiteInterface;
2625
use Magento\Store\Model\StoreManagerInterface;
2726
use Magento\Store\Model\Website;
28-
use Magento\Framework\App\ObjectManager;
29-
use Magento\Framework\View\DesignInterface;
3027

3128
/**
3229
* Class for mailing Product Alerts
3330
*
34-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
3531
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
36-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3732
*/
3833
class AlertProcessor
3934
{
@@ -85,11 +80,6 @@ class AlertProcessor
8580
*/
8681
private $errorEmailSender;
8782

88-
/**
89-
* @var DesignInterface
90-
*/
91-
private $design;
92-
9383
/**
9484
* @param EmailFactory $emailFactory
9585
* @param PriceCollectionFactory $priceCollectionFactory
@@ -100,7 +90,6 @@ class AlertProcessor
10090
* @param ProductSalability $productSalability
10191
* @param StoreManagerInterface $storeManager
10292
* @param ErrorEmailSender $errorEmailSender
103-
* @param DesignInterface|null $design
10493
*/
10594
public function __construct(
10695
EmailFactory $emailFactory,
@@ -111,8 +100,7 @@ public function __construct(
111100
Data $catalogData,
112101
ProductSalability $productSalability,
113102
StoreManagerInterface $storeManager,
114-
ErrorEmailSender $errorEmailSender,
115-
DesignInterface $design = null
103+
ErrorEmailSender $errorEmailSender
116104
) {
117105
$this->emailFactory = $emailFactory;
118106
$this->priceCollectionFactory = $priceCollectionFactory;
@@ -123,8 +111,6 @@ public function __construct(
123111
$this->productSalability = $productSalability;
124112
$this->storeManager = $storeManager;
125113
$this->errorEmailSender = $errorEmailSender;
126-
$this->design = $design ?: ObjectManager::getInstance()
127-
->get(DesignInterface::class);
128114
}
129115

130116
/**
@@ -159,12 +145,6 @@ public function process(string $alertType, array $customerIds, int $websiteId):
159145
*/
160146
private function processAlerts(string $alertType, array $customerIds, int $websiteId): array
161147
{
162-
//Set the current design theme
163-
$this->design->setDesignTheme(
164-
$this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND),
165-
Area::AREA_FRONTEND
166-
);
167-
168148
/** @var Email $email */
169149
$email = $this->emailFactory->create();
170150
$email->setType($alertType);
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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\ProductAlert\Test\Fixture;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\ProductAlert\Model\PriceFactory;
12+
use Magento\ProductAlert\Model\ResourceModel\Price;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
use Magento\TestFramework\Fixture\DataFixtureInterface;
15+
16+
class PriceAlert implements DataFixtureInterface
17+
{
18+
private const DEFAULT_DATA = [
19+
'customer_id' => null,
20+
'product_id' => null,
21+
'store_id' => 1,
22+
'website_id' => null,
23+
'price' => 11,
24+
];
25+
26+
/**
27+
* @var PriceFactory
28+
*/
29+
private PriceFactory $factory;
30+
31+
/**
32+
* @var Price
33+
*/
34+
private Price $resourceModel;
35+
36+
/**
37+
* @var StoreManagerInterface
38+
*/
39+
private StoreManagerInterface $storeManager;
40+
41+
/**
42+
* @param PriceFactory $factory
43+
* @param Price $resourceModel
44+
* @param StoreManagerInterface $storeManager
45+
*/
46+
public function __construct(
47+
PriceFactory $factory,
48+
Price $resourceModel,
49+
StoreManagerInterface $storeManager
50+
) {
51+
$this->factory = $factory;
52+
$this->resourceModel = $resourceModel;
53+
$this->storeManager = $storeManager;
54+
}
55+
56+
/**
57+
* {@inheritdoc}
58+
* @param array $data Parameters
59+
* <pre>
60+
* $data = [
61+
* 'customer_id' => (int) Customer ID. Required.
62+
* 'product_id' => (int) Product ID. Required.
63+
* 'store_id' => (int) Store ID. Optional. Default: default store.
64+
* 'website_id' => (int) Website ID. Optional. Default: default website.
65+
* 'price' => (float) Initial Price. Optional. Default: 11.
66+
* ]
67+
* </pre>
68+
*/
69+
public function apply(array $data = []): ?DataObject
70+
{
71+
$data = array_merge(self::DEFAULT_DATA, $data);
72+
$data['website_id'] ??= $this->storeManager->getStore($data['store_id'])->getWebsiteId();
73+
$model = $this->factory->create();
74+
$model->addData($data);
75+
$this->resourceModel->save($model);
76+
77+
return $model;
78+
}
79+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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\ProductAlert\Test\Fixture;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\ProductAlert\Model\StockFactory;
12+
use Magento\ProductAlert\Model\ResourceModel\Stock;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
use Magento\TestFramework\Fixture\DataFixtureInterface;
15+
16+
class StockAlert implements DataFixtureInterface
17+
{
18+
private const DEFAULT_DATA = [
19+
'customer_id' => null,
20+
'product_id' => null,
21+
'store_id' => 1,
22+
'website_id' => null,
23+
'status' => 0,
24+
];
25+
26+
/**
27+
* @var StockFactory
28+
*/
29+
private StockFactory $factory;
30+
31+
/**
32+
* @var Stock
33+
*/
34+
private Stock $resourceModel;
35+
36+
/**
37+
* @var StoreManagerInterface
38+
*/
39+
private StoreManagerInterface $storeManager;
40+
41+
/**
42+
* @param StockFactory $factory
43+
* @param Stock $resourceModel
44+
* @param StoreManagerInterface $storeManager
45+
*/
46+
public function __construct(
47+
StockFactory $factory,
48+
Stock $resourceModel,
49+
StoreManagerInterface $storeManager
50+
) {
51+
$this->factory = $factory;
52+
$this->resourceModel = $resourceModel;
53+
$this->storeManager = $storeManager;
54+
}
55+
56+
/**
57+
* {@inheritdoc}
58+
* @param array $data Parameters
59+
* <pre>
60+
* $data = [
61+
* 'customer_id' => (int) Customer ID. Required.
62+
* 'product_id' => (int) Product ID. Required.
63+
* 'store_id' => (int) Store ID. Optional. Default: default store.
64+
* 'website_id' => (int) Website ID. Optional. Default: default website.
65+
* 'status' => (int) Alert Status. Optional. Default: 0.
66+
* ]
67+
* </pre>
68+
*/
69+
public function apply(array $data = []): ?DataObject
70+
{
71+
$data = array_merge(self::DEFAULT_DATA, $data);
72+
$data['website_id'] ??= $this->storeManager->getStore($data['store_id'])->getWebsiteId();
73+
$model = $this->factory->create();
74+
$model->addData($data);
75+
$this->resourceModel->save($model);
76+
77+
return $model;
78+
}
79+
}

app/code/Magento/Store/Model/App/Emulation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ public function startEnvironmentEmulation(
147147
return;
148148
}
149149

150-
if ($storeId == $this->_storeManager->getStore()->getStoreId() && !$force) {
150+
if (!$force
151+
&& ($storeId == $this->_storeManager->getStore()->getId() && $this->_viewDesign->getArea() === $area)
152+
) {
151153
return;
152154
}
153155
$this->storeCurrentEnvironmentInfo();
Loading

0 commit comments

Comments
 (0)