Skip to content

Commit 28020ae

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop latest changes
Accepted Community Pull Requests: - #30076: Reduced html content of image details templates (by @sivaschenko) - #29979: fix incorrect image size when rendition is inserted (by @engcom-Golf) - #30044: #1832: Rename renditions stores config fieldset and add comments (by @joweecaquicla) - #29934: Fix gallery rendering on page load so current breakpoint configuration isn't replaced by any other configuration (by @Januszpl) - #25405: Fix inability to place PayPal guest order when Automatic Assignment to Customer Group is enabled (by @xylodev) - #25510: Fix for issue 25147 - Totals information management module - only set carrier/method code if set in address (by @joe-vortex) - #29274: Update Curl to respect case-insensitive headers (by @pmzandbergen) - #29542: Fix Parameter Tokenizer omitting first char of key (by @marvinhinz) Fixed GitHub Issues: - #1806: how to use require_once in magento2 (reported by @LifeAsBook) has been fixed in #29979 by @engcom-Golf in 2.4-develop branch Related commits: 1. 22da500 2. b5180c0 3. 7cfbc30 4. 9a6bd96 5. 9d0252a 6. e832db8 7. 1db2872 8. 837dd9d 9. 79ddf27 10. 1535626 11. cbc38f6 12. 0cafa20 13. ccd7251 14. 35642f7 15. f6f5a5e - #29933: Gallery multiply breakpoints options configuration doesn't work properly because of mediaCheck triggering exit media query function on page load (reported by @Januszpl) has been fixed in #29934 by @Januszpl in 2.4-develop branch Related commits: 1. faf6dfa 2. 9e53105 3. a46a395 4. c9b7a02 - #25399: Unable to place a guest order with PayPal Express when Enable Automatic Assignment to Customer Group is enabled (reported by @xylodev) has been fixed in #25405 by @xylodev in 2.4-develop branch Related commits: 1. 594fc93 2. fb299a0 3. f898245 4. 7f280cd - #25147: Totals Information Management - setting quote shipping method when address method is null (reported by @joe-vortex) has been fixed in #25510 by @joe-vortex in 2.4-develop branch Related commits: 1. a99d980 2. 1900ffc 3. 8820a5c 4. b0e0517 5. e4fb9d1 - #29524: [Issue] Update Curl to respect case-insensitive headers (reported by @m2-assistant[bot]) has been fixed in #29274 by @pmzandbergen in 2.4-develop branch Related commits: 1. 44d88e6 2. ba6513f 3. 730c495 4. 552e0c1 5. b5463b8 6. e43e45f 7. e1d21cd 8. 9570f8f 9. 9db1f83 10. d61e030 11. e912bdf 12. d5c674d - #29185: \Magento\Framework\Filter\Template\Tokenizer\Parameter (reported by @bernd-reindl) has been fixed in #29542 by @marvinhinz in 2.4-develop branch Related commits: 1. 4328a2d 2. 55a1543 3. 1b322f4
2 parents 90ab6fc + 6e255c4 commit 28020ae

File tree

30 files changed

+1010
-235
lines changed

30 files changed

+1010
-235
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryContentSection.xml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<element name="selectFromGalleryButton" type="button" selector="//*[@class='file-uploader-area']/label[text()='Select from Gallery']"/>
1515
<element name="uploadImageFile" type="input" selector=".file-uploader-area>input"/>
1616
<element name="imageFileName" type="text" selector=".file-uploader-filename"/>
17+
<element name="imageFileMeta" type="text" selector=".file-uploader-meta"/>
1718
<element name="removeImageButton" type="button" selector=".file-uploader-summary .action-remove"/>
1819
<element name="AddCMSBlock" type="select" selector="//*[@name='landing_page']"/>
1920
<element name="description" type="input" selector="//*[@name='description']"/>

app/code/Magento/Checkout/Model/TotalsInformationManagement.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Checkout\Model;
77

88
/**
9-
* Class TotalsInformationManagement
9+
* Class for management of totals information.
1010
*/
1111
class TotalsInformationManagement implements \Magento\Checkout\Api\TotalsInformationManagementInterface
1212
{
@@ -38,7 +38,7 @@ public function __construct(
3838
}
3939

4040
/**
41-
* {@inheritDoc}
41+
* @inheritDoc
4242
*/
4343
public function calculate(
4444
$cartId,
@@ -52,16 +52,20 @@ public function calculate(
5252
$quote->setBillingAddress($addressInformation->getAddress());
5353
} else {
5454
$quote->setShippingAddress($addressInformation->getAddress());
55-
$quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod(
56-
$addressInformation->getShippingCarrierCode() . '_' . $addressInformation->getShippingMethodCode()
57-
);
55+
if ($addressInformation->getShippingCarrierCode() && $addressInformation->getShippingMethodCode()) {
56+
$quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod(
57+
$addressInformation->getShippingCarrierCode().'_'.$addressInformation->getShippingMethodCode()
58+
);
59+
}
5860
}
5961
$quote->collectTotals();
6062

6163
return $this->cartTotalRepository->get($cartId);
6264
}
6365

6466
/**
67+
* Check if quote have items.
68+
*
6569
* @param \Magento\Quote\Model\Quote $quote
6670
* @throws \Magento\Framework\Exception\LocalizedException
6771
* @return void
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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\Checkout\Test\Unit\Model;
9+
10+
use Magento\Checkout\Api\Data\TotalsInformationInterface;
11+
use Magento\Checkout\Model\TotalsInformationManagement;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Quote\Api\CartRepositoryInterface;
14+
use Magento\Quote\Api\CartTotalRepositoryInterface;
15+
use Magento\Quote\Model\Quote\Address;
16+
17+
class TotalsInformationManagementTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var ObjectManager
21+
*/
22+
private $objectManager;
23+
24+
/**
25+
* @var CartRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject
26+
*/
27+
private $cartRepositoryMock;
28+
29+
/**
30+
* @var CartTotalRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject
31+
*/
32+
private $cartTotalRepositoryMock;
33+
34+
/**
35+
* @var TotalsInformationManagement
36+
*/
37+
private $totalsInformationManagement;
38+
39+
protected function setUp(): void
40+
{
41+
$this->objectManager = new ObjectManager($this);
42+
$this->cartRepositoryMock = $this->createMock(
43+
CartRepositoryInterface::class
44+
);
45+
$this->cartTotalRepositoryMock = $this->createMock(
46+
CartTotalRepositoryInterface::class
47+
);
48+
49+
$this->totalsInformationManagement = $this->objectManager->getObject(
50+
TotalsInformationManagement::class,
51+
[
52+
'cartRepository' => $this->cartRepositoryMock,
53+
'cartTotalRepository' => $this->cartTotalRepositoryMock,
54+
]
55+
);
56+
}
57+
58+
/**
59+
* Test for \Magento\Checkout\Model\TotalsInformationManagement::calculate.
60+
*
61+
* @param string|null $carrierCode
62+
* @param string|null $carrierMethod
63+
* @param int $methodSetCount
64+
* @dataProvider dataProviderCalculate
65+
*/
66+
public function testCalculate(?string $carrierCode, ?string $carrierMethod, int $methodSetCount)
67+
{
68+
$cartId = 1;
69+
$cartMock = $this->createMock(
70+
\Magento\Quote\Model\Quote::class
71+
);
72+
$cartMock->expects($this->once())->method('getItemsCount')->willReturn(1);
73+
$cartMock->expects($this->once())->method('getIsVirtual')->willReturn(false);
74+
$this->cartRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($cartMock);
75+
$this->cartTotalRepositoryMock->expects($this->once())->method('get')->with($cartId);
76+
77+
$addressInformationMock = $this->createMock(
78+
TotalsInformationInterface::class
79+
);
80+
$addressMock = $this->getMockBuilder(Address::class)
81+
->addMethods(
82+
[
83+
'setShippingMethod',
84+
'setCollectShippingRates',
85+
]
86+
)
87+
->disableOriginalConstructor()
88+
->getMock();
89+
90+
$addressInformationMock->expects($this->once())->method('getAddress')->willReturn($addressMock);
91+
$addressInformationMock->expects($this->any())->method('getShippingCarrierCode')->willReturn($carrierCode);
92+
$addressInformationMock->expects($this->any())->method('getShippingMethodCode')->willReturn($carrierMethod);
93+
$cartMock->expects($this->once())->method('setShippingAddress')->with($addressMock);
94+
$cartMock->expects($this->exactly($methodSetCount))->method('getShippingAddress')->willReturn($addressMock);
95+
$addressMock->expects($this->exactly($methodSetCount))
96+
->method('setCollectShippingRates')->with(true)->willReturn($addressMock);
97+
$addressMock->expects($this->exactly($methodSetCount))
98+
->method('setShippingMethod')->with($carrierCode . '_' . $carrierMethod);
99+
$cartMock->expects($this->once())->method('collectTotals');
100+
101+
$this->totalsInformationManagement->calculate($cartId, $addressInformationMock);
102+
}
103+
104+
/**
105+
* Data provider for testCalculate.
106+
*
107+
* @return array
108+
*/
109+
public function dataProviderCalculate(): array
110+
{
111+
return [
112+
[
113+
null,
114+
null,
115+
0
116+
],
117+
[
118+
null,
119+
'carrier_method',
120+
0
121+
],
122+
[
123+
'carrier_code',
124+
null,
125+
0
126+
],
127+
[
128+
'carrier_code',
129+
'carrier_method',
130+
1
131+
]
132+
];
133+
}
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminMediaGalleryInsertLargeImageFileSizeTest">
12+
<annotations>
13+
<features value="AdminMediaGalleryInsertLargeImageFileSizeTest"/>
14+
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1806"/>
15+
<title value="Admin user should see correct image file size after rendition"/>
16+
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1507933/scenarios/5200023"/>
17+
<stories value="User inserts image rendition to the content"/>
18+
<description value="Admin user should see correct image file size after rendition"/>
19+
<severity value="AVERAGE"/>
20+
<group value="media_gallery_ui"/>
21+
</annotations>
22+
<before>
23+
<createData entity="SimpleSubCategory" stepKey="category"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<!-- Delete uploaded image -->
28+
<actionGroup ref="AdminOpenCategoryGridPageActionGroup" stepKey="openCategoryPageFoDelete"/>
29+
<actionGroup ref="AdminEditCategoryInGridPageActionGroup" stepKey="editCategoryItemForDelete">
30+
<argument name="categoryName" value="$category.name$"/>
31+
</actionGroup>
32+
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryForDelete"/>
33+
<actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/>
34+
<actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectSecondImageToDelete">
35+
<argument name="imageName" value="{{ImageUpload.fileName}}"/>
36+
</actionGroup>
37+
<actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clickDeleteSelectedButton"/>
38+
<actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/>
39+
40+
<!-- Delete category -->
41+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
42+
</after>
43+
44+
<!-- Open category page -->
45+
<actionGroup ref="AdminOpenCategoryGridPageActionGroup" stepKey="openCategoryPage"/>
46+
<actionGroup ref="AdminEditCategoryInGridPageActionGroup" stepKey="editCategoryItem">
47+
<argument name="categoryName" value="$category.name$"/>
48+
</actionGroup>
49+
50+
<!-- Add image to category from gallery -->
51+
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGallery"/>
52+
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="addCategoryImage">
53+
<argument name="image" value="ImageUpload"/>
54+
</actionGroup>
55+
<actionGroup ref="AdminMediaGalleryClickImageInGridActionGroup" stepKey="selectImage">
56+
<argument name="imageName" value="{{ImageUpload.fileName}}"/>
57+
</actionGroup>
58+
<actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="addSelected"/>
59+
60+
61+
<!-- Assert added image size -->
62+
<actionGroup ref="AdminAssertImageUploadFileSizeThanActionGroup" stepKey="assertSize">
63+
<argument name="fileSize" value="26 KB"/>
64+
</actionGroup>
65+
</test>
66+
</tests>

app/code/Magento/MediaGalleryRenditions/etc/adminhtml/system.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
<system>
1010
<section id="system">
1111
<group id="media_gallery_renditions" translate="label" type="text" sortOrder="1010" showInDefault="1" showInWebsite="0" showInStore="0">
12-
<label>Media Gallery Renditions</label>
12+
<label>Media Gallery Image Optimization</label>
13+
<comment>Resize images to improve performance and decrease the file size. When you use an image from Media Gallery on the storefront, the smaller image is generated and placed instead of the original.
14+
Changing these settings will update all generated images.</comment>
1315
<field id="width" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
14-
<label>Max Width</label>
16+
<label>Maximum Width</label>
1517
<validate>validate-zero-or-greater validate-digits</validate>
18+
<comment>Enter the maximum width of an image in pixels.</comment>
1619
</field>
1720
<field id="height" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
18-
<label>Max Height</label>
21+
<label>Maximum Height</label>
1922
<validate>validate-zero-or-greater validate-digits</validate>
23+
<comment>Enter the maximum height of an image in pixels.</comment>
2024
</field>
2125
</group>
2226
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\MediaGalleryUi\Controller\Adminhtml\Image;
10+
11+
use Magento\Backend\App\Action;
12+
use Magento\Backend\App\Action\Context;
13+
use Magento\Framework\App\Action\HttpPostActionInterface;
14+
use Magento\Framework\Controller\Result\JsonFactory;
15+
use Magento\Framework\Controller\ResultInterface;
16+
use Magento\MediaGalleryUi\Model\InsertImageData\GetInsertImageData;
17+
18+
/**
19+
* OnInsert action returns on insert image details
20+
*/
21+
class OnInsert extends Action implements HttpPostActionInterface
22+
{
23+
/**
24+
* @see _isAllowed()
25+
*/
26+
public const ADMIN_RESOURCE = 'Magento_MediaGalleryUiApi::insert_assets';
27+
28+
/**
29+
* @var JsonFactory
30+
*/
31+
private $resultJsonFactory;
32+
33+
/**
34+
* @var GetInsertImageData
35+
*/
36+
private $getInsertImageData;
37+
38+
/**
39+
* @param Context $context
40+
* @param JsonFactory $resultJsonFactory
41+
* @param GetInsertImageData $getInsertImageData
42+
*/
43+
public function __construct(
44+
Context $context,
45+
JsonFactory $resultJsonFactory,
46+
GetInsertImageData $getInsertImageData
47+
) {
48+
parent::__construct($context);
49+
$this->resultJsonFactory = $resultJsonFactory;
50+
$this->getInsertImageData = $getInsertImageData;
51+
}
52+
53+
/**
54+
* Return a content (just a link or an html block) for inserting image to the content
55+
*
56+
* @return ResultInterface
57+
*/
58+
public function execute()
59+
{
60+
$data = $this->getRequest()->getParams();
61+
$insertImageData = $this->getInsertImageData->execute(
62+
$data['filename'],
63+
(bool)$data['force_static_path'],
64+
(bool)$data['as_is'],
65+
isset($data['store']) ? (int)$data['store'] : null
66+
);
67+
68+
return $this->resultJsonFactory->create()->setData([
69+
'content' => $insertImageData->getContent(),
70+
'size' => $insertImageData->getSize(),
71+
'type' => $insertImageData->getType(),
72+
]);
73+
}
74+
}

0 commit comments

Comments
 (0)