Skip to content

Commit 84610b2

Browse files
merge magento/2.4-develop into magento-tsg-csl3/2.4-develop-pr35
2 parents dafdac5 + 25772e6 commit 84610b2

File tree

32 files changed

+777
-54
lines changed

32 files changed

+777
-54
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAndSwitchProductType/AdminCreateSimpleProductSwitchToVirtualTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="searchForProduct">
5555
<argument name="product" value="_defaultProduct"/>
5656
</actionGroup>
57-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Virtual Product" stepKey="seeProductTypeInGrid"/>
57+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductTypeInGrid">
58+
<argument name="row" value="1"/>
59+
<argument name="column" value="Type"/>
60+
<argument name="value" value="Virtual Product"/>
61+
</actionGroup>
5862
<actionGroup ref="AssertProductInStorefrontProductPageActionGroup" stepKey="AssertProductInStorefrontProductPage">
5963
<argument name="product" value="_defaultProduct"/>
6064
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAndSwitchProductType/AdminCreateVirtualProductSwitchToSimpleTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<actionGroup ref="FillMainProductFormActionGroup" stepKey="fillProductForm">
2626
<argument name="product" value="_defaultProduct"/>
2727
</actionGroup>
28-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeProductTypeInGrid"/>
28+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductTypeInGrid">
29+
<argument name="row" value="1"/>
30+
<argument name="column" value="Type"/>
31+
<argument name="value" value="Simple Product"/>
32+
</actionGroup>
2933
</test>
3034
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest/AdminDownloadableProductTypeSwitchingToSimpleProductTest.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@
3333
<actionGroup ref="FilterProductGridBySku2ActionGroup" stepKey="filterSimpleProductGridBySku">
3434
<argument name="sku" value="$$createProduct.sku$$"/>
3535
</actionGroup>
36-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeSimpleProductNameInGrid"/>
37-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeSimpleProductTypeInGrid"/>
36+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeSimpleProductNameInGrid">
37+
<argument name="row" value="1"/>
38+
<argument name="column" value="Name"/>
39+
<argument name="value" value="$$createProduct.name$$"/>
40+
</actionGroup>
41+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeSimpleProductTypeInGrid">
42+
<argument name="row" value="1"/>
43+
<argument name="column" value="Type"/>
44+
<argument name="value" value="Simple Product"/>
45+
</actionGroup>
3846
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearSimpleProductFilters"/>
3947
<!--Assert simple product on storefront-->
4048
<comment userInput="Assert simple product on storefront" stepKey="commentAssertSimpleProductOnStorefront"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest/AdminVirtualProductTypeSwitchingToDownloadableProductTest.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@
5353
<actionGroup ref="FilterProductGridBySku2ActionGroup" stepKey="filterProductGridBySku">
5454
<argument name="sku" value="$$createProduct.sku$$"/>
5555
</actionGroup>
56-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeDownloadableProductNameInGrid"/>
57-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Downloadable Product" stepKey="seeDownloadableProductTypeInGrid"/>
56+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeDownloadableProductNameInGrid">
57+
<argument name="row" value="1"/>
58+
<argument name="column" value="Name"/>
59+
<argument name="value" value="$$createProduct.name$$"/>
60+
</actionGroup>
61+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeDownloadableProductTypeInGrid">
62+
<argument name="row" value="1"/>
63+
<argument name="column" value="Type"/>
64+
<argument name="value" value="Downloadable Product"/>
65+
</actionGroup>
5866
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearDownloadableProductFilters"/>
5967
<!--Assert downloadable product on storefront-->
6068
<comment userInput="Assert downloadable product on storefront" stepKey="commentAssertDownloadableProductOnStorefront"/>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
<argument name="keyword" value="SimpleProduct.name"/>
8080
</actionGroup>
8181
<seeNumberOfElements selector="{{AdminProductGridSection.productGridRows}}" userInput="1" stepKey="seeOnlyOneProductInGrid"/>
82-
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="{{SimpleProduct.name}}" stepKey="seeOnlySimpleProductInGrid"/>
82+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeOnlySimpleProductInGrid">
83+
<argument name="row" value="1"/>
84+
<argument name="column" value="Name"/>
85+
<argument name="value" value="{{SimpleProduct.name}}"/>
86+
</actionGroup>
8387

8488
<!--Paging works-->
8589
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="setProductGridToDefaultPagination"/>
@@ -105,7 +109,11 @@
105109
<argument name="product" value="GroupedProduct"/>
106110
</actionGroup>
107111
<seeNumberOfElements selector="{{AdminProductGridSection.productGridRows}}" userInput="1" stepKey="seeOneMatchingSkuInProductGrid"/>
108-
<see selector="{{AdminProductGridSection.productGridCell('1','SKU')}}" userInput="{{GroupedProduct.sku}}" stepKey="seeProductInFilteredGridSku"/>
112+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeProductInFilteredGridSku">
113+
<argument name="row" value="1"/>
114+
<argument name="column" value="SKU"/>
115+
<argument name="value" value="{{GroupedProduct.sku}}"/>
116+
</actionGroup>
109117
<!--Filter by price-->
110118
<actionGroup ref="FilterProductGridByPriceRangeActionGroup" stepKey="filterProductGridByPrice">
111119
<argument name="filter" value="PriceFilterRange"/>
@@ -194,7 +202,11 @@
194202
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterProductGridToCheckWeightColumn">
195203
<argument name="product" value="SimpleProduct"/>
196204
</actionGroup>
197-
<see selector="{{AdminProductGridSection.productGridCell('1','Weight')}}" userInput="{{SimpleProduct.weight}}" stepKey="seeCorrectProductWeightInGrid"/>
205+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeCorrectProductWeightInGrid">
206+
<argument name="row" value="1"/>
207+
<argument name="column" value="Weight"/>
208+
<argument name="value" value="{{SimpleProduct.weight}}"/>
209+
</actionGroup>
198210
<!--END Admin uses product grid-->
199211

200212
<!--Admin creates category-->

app/code/Magento/Catalog/view/frontend/web/js/product/list/toolbar.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,26 @@ define([
3535

3636
/** @inheritdoc */
3737
_create: function () {
38-
this._bind($(this.options.modeControl), this.options.mode, this.options.modeDefault);
39-
this._bind($(this.options.directionControl), this.options.direction, this.options.directionDefault);
40-
this._bind($(this.options.orderControl), this.options.order, this.options.orderDefault);
41-
this._bind($(this.options.limitControl), this.options.limit, this.options.limitDefault);
38+
this._bind(
39+
$(this.options.modeControl, this.element),
40+
this.options.mode,
41+
this.options.modeDefault
42+
);
43+
this._bind(
44+
$(this.options.directionControl, this.element),
45+
this.options.direction,
46+
this.options.directionDefault
47+
);
48+
this._bind(
49+
$(this.options.orderControl, this.element),
50+
this.options.order,
51+
this.options.orderDefault
52+
);
53+
this._bind(
54+
$(this.options.limitControl, this.element),
55+
this.options.limit,
56+
this.options.limitDefault
57+
);
4258
},
4359

4460
/** @inheritdoc */

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1313
use Magento\Framework\Exception\LocalizedException;
1414
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
15+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1516
use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\Tiers;
1617
use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\TiersFactory;
1718
use Magento\CatalogCustomerGraphQl\Model\Resolver\Customer\GetCustomerGroup;
@@ -60,25 +61,33 @@ class PriceTiers implements ResolverInterface
6061
*/
6162
private $priceProviderPool;
6263

64+
/**
65+
* @var PriceCurrencyInterface
66+
*/
67+
private $priceCurrency;
68+
6369
/**
6470
* @param ValueFactory $valueFactory
6571
* @param TiersFactory $tiersFactory
6672
* @param GetCustomerGroup $getCustomerGroup
6773
* @param Discount $discount
6874
* @param PriceProviderPool $priceProviderPool
75+
* @param PriceCurrencyInterface $priceCurrency
6976
*/
7077
public function __construct(
7178
ValueFactory $valueFactory,
7279
TiersFactory $tiersFactory,
7380
GetCustomerGroup $getCustomerGroup,
7481
Discount $discount,
75-
PriceProviderPool $priceProviderPool
82+
PriceProviderPool $priceProviderPool,
83+
PriceCurrencyInterface $priceCurrency
7684
) {
7785
$this->valueFactory = $valueFactory;
7886
$this->tiersFactory = $tiersFactory;
7987
$this->getCustomerGroup = $getCustomerGroup;
8088
$this->discount = $discount;
8189
$this->priceProviderPool = $priceProviderPool;
90+
$this->priceCurrency = $priceCurrency;
8291
}
8392

8493
/**
@@ -130,6 +139,7 @@ private function formatProductTierPrices(array $tierPrices, float $productPrice,
130139
$tiers = [];
131140

132141
foreach ($tierPrices as $tierPrice) {
142+
$tierPrice->setValue($this->priceCurrency->convertAndRound($tierPrice->getValue()));
133143
$percentValue = $tierPrice->getExtensionAttributes()->getPercentageValue();
134144
if ($percentValue && is_numeric($percentValue)) {
135145
$discount = $this->discount->getDiscountByPercent($productPrice, (float)$percentValue);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Query\ResolverInterface;
12+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13+
use Magento\Catalog\Api\Data\ProductInterface;
14+
use Magento\Catalog\Pricing\Price\SpecialPrice as PricingSpecialPrice;
15+
16+
/**
17+
* Resolver for Special Price
18+
*/
19+
class SpecialPrice implements ResolverInterface
20+
{
21+
/**
22+
* @inheritdoc
23+
*/
24+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
25+
{
26+
/** @var ProductInterface $product */
27+
$product = $value['model'];
28+
/** @var PricingSpecialPrice $specialPrice */
29+
$specialPrice = $product->getPriceInfo()->getPrice(PricingSpecialPrice::PRICE_CODE);
30+
31+
if ($specialPrice->getValue()) {
32+
return $specialPrice->getValue();
33+
}
34+
35+
return null;
36+
}
37+
}

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
8888
sku: String @doc(description: "A number or code assigned to a product to identify the product, options, price, and manufacturer.")
8989
description: ComplexTextValue @doc(description: "Detailed information about the product. The value can include simple HTML tags.") @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductComplexTextAttribute")
9090
short_description: ComplexTextValue @doc(description: "A short description of the product. Its use depends on the theme.") @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductComplexTextAttribute")
91-
special_price: Float @doc(description: "The discounted price of the product.")
91+
special_price: Float @doc(description: "The discounted price of the product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\SpecialPrice")
9292
special_from_date: String @doc(description: "The beginning date that a product has a special price.")
9393
special_to_date: String @doc(description: "The end date that a product has a special price.")
9494
attribute_set_id: Int @doc(description: "The attribute set assigned to the product.")

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,12 @@ public function resizeFile($source, $keepRatio = true)
628628
}
629629
$image = $this->_imageFactory->create();
630630
$image->open($source);
631+
631632
$image->keepAspectRatio($keepRatio);
632-
$image->resize($this->_resizeParameters['width'], $this->_resizeParameters['height']);
633+
634+
list($imageWidth, $imageHeight) = $this->getResizedParams($source);
635+
636+
$image->resize($imageWidth, $imageHeight);
633637
$dest = $targetDir . '/' . $this->ioFile->getPathInfo($source)['basename'];
634638
$image->save($dest);
635639
if ($this->_directory->isFile($this->_directory->getRelativePath($dest))) {
@@ -638,6 +642,29 @@ public function resizeFile($source, $keepRatio = true)
638642
return false;
639643
}
640644

645+
/**
646+
* Return width height for the image resizing.
647+
*
648+
* @param string $source
649+
* @return array
650+
*/
651+
private function getResizedParams(string $source): array
652+
{
653+
$configWidth = $this->_resizeParameters['width'];
654+
$configHeight = $this->_resizeParameters['height'];
655+
656+
//phpcs:ignore Generic.PHP.NoSilencedErrors
657+
list($imageWidth, $imageHeight) = @getimagesize($source);
658+
659+
if ($imageWidth && $imageHeight) {
660+
$imageWidth = $configWidth > $imageWidth ? $imageWidth : $configWidth;
661+
$imageHeight = $configHeight > $imageHeight ? $imageHeight : $configHeight;
662+
663+
return [$imageWidth, $imageHeight];
664+
}
665+
return [$configWidth, $configHeight];
666+
}
667+
641668
/**
642669
* Resize images on the fly in controller action
643670
*

0 commit comments

Comments
 (0)