Skip to content

Commit 80fd646

Browse files
authored
Merge pull request #4373 from magento-troll/MC-17533
[Troll][Performance] Bug fixes - MC-17533 'Apply Coupon To Cart' benchmark scenario fix - MC-17511 Move fonts preload from blank to luma - MC-17583 Slow work resize images
2 parents bcfe16f + c2603c4 commit 80fd646

File tree

6 files changed

+16
-76
lines changed

6 files changed

+16
-76
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ private function getUsedImagesSelect(): Select
158158
'value as filepath'
159159
)->joinInner(
160160
['image_value' => $this->resourceConnection->getTableName(Gallery::GALLERY_VALUE_TABLE)],
161-
'images.value_id = image_value.value_id'
161+
'images.value_id = image_value.value_id',
162+
[]
162163
)->where(
163164
'images.disabled = 0 AND image_value.disabled = 0'
164165
);

app/code/Magento/Theme/Controller/Result/AsyncCssPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function beforeSendResponse(Http $subject): void
4141
{
4242
$content = $subject->getContent();
4343

44-
if (strpos($content, '</body') !== false && $this->scopeConfig->isSetFlag(
44+
if (\is_string($content) && strpos($content, '</body') !== false && $this->scopeConfig->isSetFlag(
4545
self::XML_PATH_USE_CSS_CRITICAL_PATH,
4646
ScopeInterface::SCOPE_STORE
4747
)) {

app/design/frontend/Magento/blank/Magento_Theme/layout/default_head_blocks.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<css src="css/styles-m.css"/>
1111
<css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
1212
<css src="css/print.css" media="print"/>
13-
<font src="fonts/opensans/light/opensans-300.woff2"/>
14-
<font src="fonts/opensans/regular/opensans-400.woff2"/>
15-
<font src="fonts/opensans/semibold/opensans-600.woff2"/>
16-
<font src="fonts/opensans/bold/opensans-700.woff2"/>
17-
<font src="fonts/Luma-Icons.woff2"/>
1813
<meta name="format-detection" content="telephone=no"/>
1914
</head>
2015
</page>

app/design/frontend/Magento/luma/Magento_Theme/layout/default_head_blocks.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<head>
1010
<meta name="viewport" content="width=device-width, initial-scale=1"/>
11+
<font src="fonts/opensans/light/opensans-300.woff2"/>
12+
<font src="fonts/opensans/regular/opensans-400.woff2"/>
13+
<font src="fonts/opensans/semibold/opensans-600.woff2"/>
14+
<font src="fonts/opensans/bold/opensans-700.woff2"/>
15+
<font src="fonts/Luma-Icons.woff2"/>
1116
</head>
1217
</page>

setup/src/Magento/Setup/Fixtures/CouponCodesFixture.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,54 +71,35 @@ public function execute()
7171

7272
/** @var \Magento\Store\Model\StoreManager $storeManager */
7373
$storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class);
74-
/** @var $category \Magento\Catalog\Model\Category */
75-
$category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class);
7674

7775
//Get all websites
78-
$categoriesArray = [];
76+
$websitesArray = [];
7977
$websites = $storeManager->getWebsites();
8078
foreach ($websites as $website) {
81-
//Get all groups
82-
$websiteGroups = $website->getGroups();
83-
foreach ($websiteGroups as $websiteGroup) {
84-
$websiteGroupRootCategory = $websiteGroup->getRootCategoryId();
85-
$category->load($websiteGroupRootCategory);
86-
$categoryResource = $category->getResource();
87-
//Get all categories
88-
$resultsCategories = $categoryResource->getAllChildren($category);
89-
foreach ($resultsCategories as $resultsCategory) {
90-
$category->load($resultsCategory);
91-
$structure = explode('/', $category->getPath());
92-
if (count($structure) > 2) {
93-
$categoriesArray[] = [$category->getId(), $website->getId()];
94-
}
95-
}
96-
}
79+
$websitesArray[] = $website->getId();
9780
}
98-
asort($categoriesArray);
99-
$categoriesArray = array_values($categoriesArray);
10081

101-
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $categoriesArray);
82+
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $websitesArray);
10283
}
10384

10485
/**
10586
* Generate Coupon Codes
10687
*
10788
* @param \Magento\SalesRule\Model\RuleFactory $ruleFactory
10889
* @param \Magento\SalesRule\Model\CouponFactory $couponCodeFactory
109-
* @param array $categoriesArray
90+
* @param array $websitesArray
11091
*
11192
* @return void
11293
*/
113-
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $categoriesArray)
94+
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $websitesArray)
11495
{
11596
for ($i = 0; $i < $this->couponCodesCount; $i++) {
11697
$ruleName = sprintf('Coupon Code %1$d', $i);
11798
$data = [
11899
'rule_id' => null,
119100
'name' => $ruleName,
120101
'is_active' => '1',
121-
'website_ids' => $categoriesArray[$i % count($categoriesArray)][1],
102+
'website_ids' => $websitesArray,
122103
'customer_group_ids' => [
123104
0 => '0',
124105
1 => '1',

setup/src/Magento/Setup/Test/Unit/Fixtures/CouponCodesFixtureTest.php

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -56,60 +56,20 @@ public function setUp()
5656
*/
5757
public function testExecute()
5858
{
59-
$storeMock = $this->createMock(\Magento\Store\Model\Store::class);
60-
$storeMock->expects($this->once())
61-
->method('getRootCategoryId')
62-
->will($this->returnValue(2));
63-
6459
$websiteMock = $this->createMock(\Magento\Store\Model\Website::class);
65-
$websiteMock->expects($this->once())
66-
->method('getGroups')
67-
->will($this->returnValue([$storeMock]));
6860
$websiteMock->expects($this->once())
6961
->method('getId')
7062
->will($this->returnValue('website_id'));
7163

72-
$contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class);
73-
$abstractDbMock = $this->getMockForAbstractClass(
74-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class,
75-
[$contextMock],
76-
'',
77-
true,
78-
true,
79-
true,
80-
['getAllChildren']
81-
);
82-
$abstractDbMock->expects($this->once())
83-
->method('getAllChildren')
84-
->will($this->returnValue([1]));
85-
8664
$storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class);
8765
$storeManagerMock->expects($this->once())
8866
->method('getWebsites')
8967
->will($this->returnValue([$websiteMock]));
9068

91-
$categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
92-
$categoryMock->expects($this->once())
93-
->method('getResource')
94-
->will($this->returnValue($abstractDbMock));
95-
$categoryMock->expects($this->once())
96-
->method('getPath')
97-
->will($this->returnValue('path/to/file'));
98-
$categoryMock->expects($this->once())
99-
->method('getId')
100-
->will($this->returnValue('category_id'));
101-
102-
$objectValueMap = [
103-
[\Magento\Catalog\Model\Category::class, $categoryMock]
104-
];
105-
10669
$objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
10770
$objectManagerMock->expects($this->once())
10871
->method('create')
10972
->will($this->returnValue($storeManagerMock));
110-
$objectManagerMock->expects($this->once())
111-
->method('get')
112-
->will($this->returnValueMap($objectValueMap));
11373

11474
$valueMap = [
11575
['coupon_codes', 0, 1]
@@ -120,7 +80,7 @@ public function testExecute()
12080
->method('getValue')
12181
->will($this->returnValueMap($valueMap));
12282
$this->fixtureModelMock
123-
->expects($this->exactly(2))
83+
->expects($this->exactly(1))
12484
->method('getObjectManager')
12585
->will($this->returnValue($objectManagerMock));
12686

@@ -191,8 +151,6 @@ public function testGetActionTitle()
191151
*/
192152
public function testIntroduceParamLabels()
193153
{
194-
$this->assertSame([
195-
'coupon_codes' => 'Coupon Codes'
196-
], $this->model->introduceParamLabels());
154+
$this->assertSame(['coupon_codes' => 'Coupon Codes'], $this->model->introduceParamLabels());
197155
}
198156
}

0 commit comments

Comments
 (0)