Skip to content

Commit d1ec840

Browse files
committed
Merge remote-tracking branch 'origin/MC-31832' into 2.4-develop-pr23
2 parents dcaee49 + 94a0dc5 commit d1ec840

File tree

16 files changed

+28
-334
lines changed

16 files changed

+28
-334
lines changed

app/code/Magento/Catalog/Model/Layer/FilterList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ protected function getAttributeFilterClass(\Magento\Catalog\Model\ResourceModel\
123123
{
124124
$filterClassName = $this->filterTypes[self::ATTRIBUTE_FILTER];
125125

126-
if ($attribute->getFrontendInput() === 'price') {
126+
if ($attribute->getAttributeCode() == 'price') {
127127
$filterClassName = $this->filterTypes[self::PRICE_FILTER];
128-
} elseif ($attribute->getBackendType() === 'decimal') {
128+
} elseif ($attribute->getBackendType() == 'decimal') {
129129
$filterClassName = $this->filterTypes[self::DECIMAL_FILTER];
130130
}
131131

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,28 +282,6 @@
282282
<data key="used_for_sort_by">false</data>
283283
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
284284
</entity>
285-
<entity name="productAttributeTypeOfPrice" type="ProductAttribute">
286-
<data key="attribute_code" unique="suffix">attribute</data>
287-
<data key="frontend_input">price</data>
288-
<data key="scope">global</data>
289-
<data key="is_required">false</data>
290-
<data key="is_unique">false</data>
291-
<data key="is_searchable">false</data>
292-
<data key="is_visible">true</data>
293-
<data key="is_wysiwyg_enabled">false</data>
294-
<data key="is_visible_in_advanced_search">false</data>
295-
<data key="is_visible_on_front">true</data>
296-
<data key="is_filterable">true</data>
297-
<data key="is_filterable_in_search">false</data>
298-
<data key="used_in_product_listing">false</data>
299-
<data key="is_used_for_promo_rules">false</data>
300-
<data key="is_comparable">true</data>
301-
<data key="is_used_in_grid">false</data>
302-
<data key="is_visible_in_grid">false</data>
303-
<data key="is_filterable_in_grid">false</data>
304-
<data key="used_for_sort_by">false</data>
305-
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
306-
</entity>
307285
<entity name="textProductAttribute" extends="productAttributeWysiwyg" type="ProductAttribute">
308286
<data key="frontend_input">text</data>
309287
<data key="default_value" unique="suffix">defaultValue</data>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
<section name="StorefrontCategoryFilterSection">
1212
<element name="CategoryFilter" type="button" selector="//main//div[@class='filter-options']//div[contains(text(), 'Category')]"/>
1313
<element name="CategoryByName" type="button" selector="//main//div[@class='filter-options']//li[@class='item']//a[contains(text(), '{{var1}}')]" parameterized="true"/>
14-
<element name="CustomPriceAttribute" type="button" selector="div.filter-options-title"/>
1514
</section>
1615
</sections>

app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@ public function testGetFilters($method, $value, $expectedClass)
9494

9595
$this->objectManagerMock->expects($this->at(1))
9696
->method('create')
97-
->with(
98-
$expectedClass,
99-
[
100-
'data' => ['attribute_model' => $this->attributeMock],
101-
'layer' => $this->layerMock
102-
]
103-
)
97+
->with($expectedClass, [
98+
'data' => ['attribute_model' => $this->attributeMock],
99+
'layer' => $this->layerMock])
104100
->will($this->returnValue('filter'));
105101

106102
$this->attributeMock->expects($this->once())
@@ -169,8 +165,8 @@ public function getFiltersDataProvider()
169165
{
170166
return [
171167
[
172-
'method' => 'getFrontendInput',
173-
'value' => 'price',
168+
'method' => 'getAttributeCode',
169+
'value' => FilterList::PRICE_FILTER,
174170
'expectedClass' => 'PriceFilterClass',
175171
],
176172
[
@@ -179,8 +175,8 @@ public function getFiltersDataProvider()
179175
'expectedClass' => 'DecimalFilterClass',
180176
],
181177
[
182-
'method' => 'getFrontendInput',
183-
'value' => 'text',
178+
'method' => 'getAttributeCode',
179+
'value' => null,
184180
'expectedClass' => 'AttributeFilterClass',
185181
]
186182
];
@@ -195,8 +191,8 @@ public function getFiltersWithoutCategoryDataProvider(): array
195191
{
196192
return [
197193
'Filters contains only price attribute' => [
198-
'method' => 'getFrontendInput',
199-
'value' => 'price',
194+
'method' => 'getAttributeCode',
195+
'value' => FilterList::PRICE_FILTER,
200196
'expectedClass' => 'PriceFilterClass',
201197
'expectedResult' => [
202198
'filter'

app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
class Decimal extends AbstractFilter
1616
{
17-
/** Decimal delta for filter */
18-
private const DECIMAL_DELTA = 0.001;
19-
2017
/**
2118
* @var \Magento\Framework\Pricing\PriceCurrencyInterface
2219
*/
@@ -75,17 +72,11 @@ public function apply(\Magento\Framework\App\RequestInterface $request)
7572

7673
list($from, $to) = explode('-', $filter);
7774

78-
// When the range is 10-20 we only need to get products that are in the 10-19.99 range.
79-
$toValue = $to;
80-
if (!empty($toValue) && $from !== $toValue) {
81-
$toValue -= self::DECIMAL_DELTA;
82-
}
83-
8475
$this->getLayer()
8576
->getProductCollection()
8677
->addFieldToFilter(
8778
$this->getAttributeModel()->getAttributeCode(),
88-
['from' => $from, 'to' => $toValue]
79+
['from' => $from, 'to' => $to]
8980
);
9081

9182
$this->getLayer()->getState()->addFilter(
@@ -122,7 +113,7 @@ protected function _getItemsData()
122113
$from = '';
123114
}
124115
if ($to == '*') {
125-
$to = '';
116+
$to = null;
126117
}
127118
$label = $this->renderRangeLabel(empty($from) ? 0 : $from, $to);
128119
$value = $from . '-' . $to;
@@ -149,7 +140,7 @@ protected function _getItemsData()
149140
protected function renderRangeLabel($fromPrice, $toPrice)
150141
{
151142
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
152-
if ($toPrice === '') {
143+
if ($toPrice === null) {
153144
return __('%1 and above', $formattedFromPrice);
154145
} else {
155146
if ($fromPrice != $toPrice) {

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request)
141141
list($from, $to) = $filter;
142142

143143
$this->getLayer()->getProductCollection()->addFieldToFilter(
144-
$this->getAttributeModel()->getAttributeCode(),
144+
'price',
145145
['from' => $from, 'to' => empty($to) || $from == $to ? $to : $to - self::PRICE_DELTA]
146146
);
147147

app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ private function generateRequest($attributeType, $container, $useFulltext)
100100
],
101101
];
102102
$bucketName = $attribute->getAttributeCode() . self::BUCKET_SUFFIX;
103-
$generatorType = $attribute->getFrontendInput() === 'price'
104-
? $attribute->getFrontendInput()
105-
: $attribute->getBackendType();
106-
$generator = $this->generatorResolver->getGeneratorForType($generatorType);
103+
$generator = $this->generatorResolver->getGeneratorForType($attribute->getBackendType());
107104
$request['filters'][$filterName] = $generator->getFilterData($attribute, $filterName);
108105
$request['aggregations'][$bucketName] = $generator->getAggregationData($attribute, $bucketName);
109106
}

app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/Price.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

app/code/Magento/CatalogSearch/Test/Mftf/Test/LayerNavigationOfCatalogSearchTest.xml

Lines changed: 0 additions & 92 deletions
This file was deleted.

app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/PriceTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ public function testApply()
209209
$priceId = '15-50';
210210
$requestVar = 'test_request_var';
211211

212-
$this->target->setAttributeModel($this->attribute);
213-
$attributeCode = 'price';
214-
$this->attribute->expects($this->any())
215-
->method('getAttributeCode')
216-
->will($this->returnValue($attributeCode));
217-
218212
$this->target->setRequestVar($requestVar);
219213
$this->request->expects($this->exactly(1))
220214
->method('getParam')

0 commit comments

Comments
 (0)