Skip to content

Commit c9b0983

Browse files
Merge branch '2.4-develop' into commpr-21755-2209
2 parents ebea444 + e885088 commit c9b0983

File tree

53 files changed

+2936
-1239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2936
-1239
lines changed

app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleRegularPriceTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testGetAmount()
9898
->willReturn($expectedResult);
9999

100100
$this->priceCurrencyMock->expects($this->once())
101-
->method('convertAndRound')
101+
->method('convert')
102102
->willReturnArgument(0);
103103

104104
$result = $this->regularPrice->getAmount();
@@ -123,7 +123,7 @@ public function testGetMaximalPrice()
123123
->willReturn($expectedResult);
124124

125125
$this->priceCurrencyMock->expects($this->once())
126-
->method('convertAndRound')
126+
->method('convert')
127127
->willReturnArgument(0);
128128

129129
$result = $this->regularPrice->getMaximalPrice();
@@ -165,7 +165,7 @@ public function testGetMaximalPriceForFixedPriceBundleWithOption()
165165
->willReturn($expectedPrice);
166166

167167
$this->priceCurrencyMock->expects($this->once())
168-
->method('convertAndRound')
168+
->method('convert')
169169
->willReturnArgument(0);
170170

171171
$result = $this->regularPrice->getMaximalPrice();
@@ -185,7 +185,7 @@ public function testGetMinimalPrice()
185185
->willReturn($expectedResult);
186186

187187
$this->priceCurrencyMock->expects($this->once())
188-
->method('convertAndRound')
188+
->method('convert')
189189
->willReturnArgument(0);
190190

191191
$this->bundleCalculatorMock->expects($this->once())
@@ -226,7 +226,7 @@ public function testGetMinimalPriceForFixedPricedBundleWithOptions()
226226
->willReturn($minOptionPrice);
227227

228228
$this->priceCurrencyMock->expects($this->once())
229-
->method('convertAndRound')
229+
->method('convert')
230230
->willReturnArgument(0);
231231

232232
$this->bundleCalculatorMock->expects($this->once())

app/code/Magento/Catalog/Pricing/Price/RegularPrice.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
1111

1212
/**
13-
* Class RegularPrice
13+
* Regular Price model
1414
*/
1515
class RegularPrice extends AbstractPrice implements BasePriceProviderInterface
1616
{
1717
/**
1818
* Price type
1919
*/
20-
const PRICE_CODE = 'regular_price';
20+
public const PRICE_CODE = 'regular_price';
2121

2222
/**
2323
* Get price value
@@ -28,7 +28,7 @@ public function getValue()
2828
{
2929
if ($this->value === null) {
3030
$price = $this->product->getPrice();
31-
$priceInCurrentCurrency = $this->priceCurrency->convertAndRound($price);
31+
$priceInCurrentCurrency = $this->priceCurrency->convert($price);
3232
$this->value = $priceInCurrentCurrency ? (float)$priceInCurrentCurrency : 0;
3333
}
3434
return $this->value;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<element name="asLowAsLabel" type="input" selector="//strong[@id='block-related-heading']/following::span[@class='price-label'][1]"/>
3737
<element name="asLowAsLabelAgain" type="input" selector="//strong[@id='block-related-heading']/following::span[@class='price-label'][2]"/>
3838
<element name="specialPriceValue" type="text" selector="//span[@class='special-price']//span[@class='price']"/>
39-
<element name="mapPrice" type="text" selector="//div[@class='price-box price-final_price']//span[contains(@class, 'price-msrp_price')]"/>
39+
<element name="mapPrice" type="text" selector="//div[@class='price-box price-final_price']//span[contains(@class, 'price-msrp_price')]//span"/>
4040
<element name="clickForPriceLink" type="text" selector="//div[@class='price-box price-final_price']//a[contains(text(), 'Click for price')]"/>
4141
<element name="addReviewLink" type="text" selector="//div[@class='reviews-actions']//a[@class='action add']"/>
4242
<element name="fptPrice" type="text" selector=".//*[@class='weee']/span"/>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="StorefrontAssertsCustomerBehaviourForProductTest">
11+
<test name="StorefrontAssertsCustomerBehaviourForProductTest" deprecated="Use StorefrontSearchToolbarTest instead">
1212
<annotations>
1313
<features value="Catalog"/>
1414
<stories value="Product Sorting for guest/customer in storefront"/>
@@ -17,6 +17,9 @@
1717
<severity value="MAJOR"/>
1818
<testCaseId value="AC-8905"/>
1919
<group value="catalog"/>
20+
<skip>
21+
<issueId value="DEPRECATED">Use StorefrontSearchToolbarTest instead</issueId>
22+
</skip>
2023
</annotations>
2124
<before>
2225
<!-- Precondition Step.1: Magento should be installed.with Sample Data -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<argument name="currency" value="EUR"/>
6262
</actionGroup>
6363
<actionGroup ref="AssertStorefrontCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionEUR">
64-
<argument name="price" value="8.7"/>
64+
<argument name="price" value="8.69"/>
6565
</actionGroup>
6666
</test>
6767
</tests>

app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testGetValue($price)
8080
->method('getPrice')
8181
->willReturn($price);
8282
$this->priceCurrencyMock->expects($this->any())
83-
->method('convertAndRound')
83+
->method('convert')
8484
->with($price)
8585
->willReturn($convertedPrice);
8686
$this->assertEquals($convertedPrice, $this->regularPrice->getValue());
@@ -114,7 +114,7 @@ public function testGetAmount()
114114
->method('getPrice')
115115
->willReturn($priceValue);
116116
$this->priceCurrencyMock->expects($this->any())
117-
->method('convertAndRound')
117+
->method('convert')
118118
->with($priceValue)
119119
->willReturn($convertedPrice);
120120
$this->calculatorMock->expects($this->once())

app/code/Magento/CatalogSearch/Controller/Result/Index.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\Store\Model\StoreManagerInterface;
1414
use Magento\Search\Model\QueryFactory;
1515
use Magento\Search\Model\PopularSearchTerms;
16+
use Magento\Catalog\Model\Product\ProductList\ToolbarMemorizer;
17+
use Magento\Catalog\Model\Product\ProductList\Toolbar;
1618

1719
/**
1820
* Search result.
@@ -22,10 +24,10 @@ class Index extends \Magento\Framework\App\Action\Action implements HttpGetActio
2224
/**
2325
* No results default handle.
2426
*/
25-
const DEFAULT_NO_RESULT_HANDLE = 'catalogsearch_result_index_noresults';
27+
public const DEFAULT_NO_RESULT_HANDLE = 'catalogsearch_result_index_noresults';
2628

2729
/**
28-
* Catalog session
30+
* Catalog session for storing catalog-related data
2931
*
3032
* @var Session
3133
*/
@@ -48,25 +50,34 @@ class Index extends \Magento\Framework\App\Action\Action implements HttpGetActio
4850
*/
4951
private $layerResolver;
5052

53+
/**
54+
* @var ToolbarMemorizer
55+
*/
56+
private $toolbarMemorizer;
57+
5158
/**
5259
* @param Context $context
5360
* @param Session $catalogSession
5461
* @param StoreManagerInterface $storeManager
5562
* @param QueryFactory $queryFactory
5663
* @param Resolver $layerResolver
64+
* @param ToolbarMemorizer|null $toolbarMemorizer
5765
*/
5866
public function __construct(
5967
Context $context,
6068
Session $catalogSession,
6169
StoreManagerInterface $storeManager,
6270
QueryFactory $queryFactory,
63-
Resolver $layerResolver
71+
Resolver $layerResolver,
72+
?ToolbarMemorizer $toolbarMemorizer = null
6473
) {
6574
parent::__construct($context);
6675
$this->_storeManager = $storeManager;
6776
$this->_catalogSession = $catalogSession;
6877
$this->_queryFactory = $queryFactory;
6978
$this->layerResolver = $layerResolver;
79+
$this->toolbarMemorizer = $toolbarMemorizer ?:
80+
\Magento\Framework\App\ObjectManager::getInstance()->get(ToolbarMemorizer::class);
7081
}
7182

7283
/**
@@ -101,6 +112,11 @@ public function execute()
101112
$handles[] = static::DEFAULT_NO_RESULT_HANDLE;
102113
}
103114

115+
if ($this->shouldRedirectOnToolbarAction()) {
116+
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
117+
return;
118+
}
119+
104120
if (empty($getAdditionalRequestParameters) &&
105121
$this->_objectManager->get(PopularSearchTerms::class)->isCacheable($queryText, $storeId)
106122
) {
@@ -166,4 +182,21 @@ private function getNotCacheableResult($catalogSearchHelper, $query, $handles)
166182
$this->getResponse()->setNoCacheHeaders();
167183
$this->_view->renderLayout();
168184
}
185+
186+
/**
187+
* Checks for toolbar actions
188+
*
189+
* @return bool
190+
*/
191+
private function shouldRedirectOnToolbarAction(): bool
192+
{
193+
$params = $this->getRequest()->getParams();
194+
195+
return $this->toolbarMemorizer->isMemorizingAllowed() && empty(array_intersect([
196+
Toolbar::ORDER_PARAM_NAME,
197+
Toolbar::DIRECTION_PARAM_NAME,
198+
Toolbar::MODE_PARAM_NAME,
199+
Toolbar::LIMIT_PARAM_NAME
200+
], array_keys($params))) === false;
201+
}
169202
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
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="StorefrontSearchSetDefaultDisplaySettingsActionGroup">
12+
<annotations>
13+
<description>Sets search display to default settings: grid mode, relevance descending, 12 items per page. Fails if not on search results page.</description>
14+
</annotations>
15+
16+
<!-- Check if we're on the search results page -->
17+
<seeInCurrentUrl url="{{StorefrontCatalogSearchPage.url}}" stepKey="verifyOnSearchPage"/>
18+
19+
<!-- Set display mode to grid (default) -->
20+
<click selector="{{StorefrontSearchTopToolbarSection.gridMode}}" stepKey="selectGridMode"/>
21+
<waitForPageLoad stepKey="waitForGridModeApplied"/>
22+
23+
<!-- Set sort field to relevance (default for search) -->
24+
<selectOption selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="relevance" stepKey="selectSortByRelevance"/>
25+
<waitForPageLoad stepKey="waitForRelevanceSortingApplied"/>
26+
27+
<!-- If currently ascending, click to change to descending -->
28+
<conditionalClick
29+
selector="{{StorefrontSearchTopToolbarSection.sortDirectionAsc}}"
30+
dependentSelector="{{StorefrontSearchTopToolbarSection.sortDirectionAsc}}"
31+
visible="true"
32+
stepKey="clickAscendingIfVisible"/>
33+
34+
<!-- Set items per page to 12 (default) -->
35+
<selectOption selector="{{StorefrontSearchTopToolbarSection.showDropdown}}" userInput="12" stepKey="selectItemsPerPage12"/>
36+
<waitForPageLoad stepKey="waitForSettingsApplied"/>
37+
38+
<!-- Verify all default settings are properly applied -->
39+
<seeElement selector="{{StorefrontSearchTopToolbarSection.gridMode}}" stepKey="verifyGridModeSelected"/>
40+
<seeOptionIsSelected selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="relevance" stepKey="verifyRelevanceSortSelected"/>
41+
<seeElement selector="{{StorefrontSearchTopToolbarSection.sortDirectionDesc}}" stepKey="verifyDescendingSortDirection"/>
42+
<seeOptionIsSelected selector="{{StorefrontSearchTopToolbarSection.showDropdown}}" userInput="12" stepKey="verify12ItemsPerPageSelected"/>
43+
</actionGroup>
44+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontSearchTopToolbarSection">
12+
<element name="searchResultsToolbar" type="block" selector=".toolbar.toolbar-products" timeout="30"/>
13+
<element name="gridMode" type="button" selector=".toolbar.toolbar-products .modes .mode-grid" timeout="30"/>
14+
<element name="listMode" type="button" selector=".toolbar.toolbar-products .modes .mode-list" timeout="30"/>
15+
<element name="sortByDropdown" type="select" selector=".toolbar.toolbar-products .sorter #sorter" timeout="30"/>
16+
<element name="sortDirectionAsc" type="button" selector=".toolbar.toolbar-products .sorter a.sort-asc" timeout="30"/>
17+
<element name="sortDirectionDesc" type="button" selector=".toolbar.toolbar-products .sorter a.sort-desc" timeout="30"/>
18+
<element name="showDropdown" type="select" selector=".toolbar.toolbar-products .limiter #limiter" timeout="30"/>
19+
</section>
20+
</sections>

0 commit comments

Comments
 (0)