Skip to content

Commit 8513dfd

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop expedited
Accepted Community Pull Requests: - #28547: 'Ship Here' in CamelCase as that's how it is written elsewhere (by @woutk88) - #28222: [Wishlist] Giving the possibility to set/update item description on item update (by @eduard13) - #28015: Fix #28011 - remove page number from query on layered navigation swatch filter (by @Bartlomiejsz) Fixed GitHub Issues: - #28261: [Issue] [Wishlist] Giving the possibility to set/update item description on item update (reported by @m2-backlog[bot]) has been fixed in #28222 by @eduard13 in 2.4-develop branch Related commits: 1. a41e384 2. 1d799ab - #28011: ElasticSearch When applying the extra filter to the product listing, Magento keeps the same page number (reported by @santosh-gaggle) has been fixed in #28015 by @Bartlomiejsz in 2.4-develop branch Related commits: 1. 92b29c6 2. 475be33 3. 7630cb0 4. 0de77c8 5. ee4acff
2 parents bb176b8 + 249ce6d commit 8513dfd

File tree

10 files changed

+338
-68
lines changed

10 files changed

+338
-68
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontCategoryCurrentPageIsNthActionGroup">
11+
<arguments>
12+
<argument name="expectedPage" type="string"/>
13+
</arguments>
14+
15+
<grabTextFrom selector="{{StorefrontCategoryBottomToolbarSection.currentPage}}" stepKey="currentPageText"/>
16+
<assertEquals stepKey="assertIsPageNth">
17+
<expectedResult type="string">{{expectedPage}}</expectedResult>
18+
<actualResult type="variable">currentPageText</actualResult>
19+
</assertEquals>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<actionGroup name="StorefrontNavigateCategoryNextPageActionGroup">
10+
<annotations>
11+
<description>Navigates storefront category next page from toolbar</description>
12+
</annotations>
13+
<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
14+
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
15+
<waitForPageLoad stepKey="waitForNextCategoryPageLoad"/>
16+
</actionGroup>
17+
</actionGroups>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<element name="previousPage" type="button" selector=".//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'previous')]" timeout="30"/>
1313
<element name="pageNumber" type="text" selector="//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'page')]//span[2][contains(text() ,'{{var1}}')]" parameterized="true"/>
1414
<element name="perPage" type="select" selector="//*[@class='toolbar toolbar-products'][2]//select[@id='limiter']"/>
15-
<element name="currentPage" type="text" selector=".products.wrapper + .toolbar-products .pages .current span:nth-of-type(2)"/>
15+
<element name="currentPage" type="text" selector=".//*[@class='toolbar toolbar-products'][2]//li[contains(@class, 'current')]//span[2]" timeout="30"/>
1616
</section>
1717
</sections>

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<item name="trigger" xsi:type="string">opc-new-shipping-address</item>
106106
<item name="buttons" xsi:type="array">
107107
<item name="save" xsi:type="array">
108-
<item name="text" xsi:type="string" translate="true">Ship here</item>
108+
<item name="text" xsi:type="string" translate="true">Ship Here</item>
109109
<item name="class" xsi:type="string">action primary action-save-address</item>
110110
</item>
111111
<item name="cancel" xsi:type="array">

app/code/Magento/Swatches/Block/LayeredNavigation/RenderLayered.php

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
*/
66
namespace Magento\Swatches\Block\LayeredNavigation;
77

8-
use Magento\Eav\Model\Entity\Attribute;
8+
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
9+
use Magento\Catalog\Model\Layer\Filter\Item as FilterItem;
910
use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory;
10-
use Magento\Framework\View\Element\Template;
11+
use Magento\Eav\Model\Entity\Attribute;
1112
use Magento\Eav\Model\Entity\Attribute\Option;
12-
use Magento\Catalog\Model\Layer\Filter\Item as FilterItem;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\View\Element\Template;
15+
use Magento\Framework\View\Element\Template\Context;
16+
use Magento\Swatches\Helper\Data;
17+
use Magento\Swatches\Helper\Media;
18+
use Magento\Theme\Block\Html\Pager;
1319

1420
/**
1521
* Class RenderLayered Render Swatches at Layered Navigation
@@ -37,7 +43,7 @@ class RenderLayered extends Template
3743
protected $eavAttribute;
3844

3945
/**
40-
* @var \Magento\Catalog\Model\Layer\Filter\AbstractFilter
46+
* @var AbstractFilter
4147
*/
4248
protected $filter;
4349

@@ -47,41 +53,52 @@ class RenderLayered extends Template
4753
protected $layerAttribute;
4854

4955
/**
50-
* @var \Magento\Swatches\Helper\Data
56+
* @var Data
5157
*/
5258
protected $swatchHelper;
5359

5460
/**
55-
* @var \Magento\Swatches\Helper\Media
61+
* @var Media
5662
*/
5763
protected $mediaHelper;
5864

5965
/**
60-
* @param Template\Context $context
66+
* @var Pager
67+
*/
68+
private $htmlPagerBlock;
69+
70+
/**
71+
* @param Context $context
6172
* @param Attribute $eavAttribute
6273
* @param AttributeFactory $layerAttribute
63-
* @param \Magento\Swatches\Helper\Data $swatchHelper
64-
* @param \Magento\Swatches\Helper\Media $mediaHelper
74+
* @param Data $swatchHelper
75+
* @param Media $mediaHelper
6576
* @param array $data
77+
* @param Pager|null $htmlPagerBlock
6678
*/
6779
public function __construct(
68-
\Magento\Framework\View\Element\Template\Context $context,
80+
Context $context,
6981
Attribute $eavAttribute,
7082
AttributeFactory $layerAttribute,
71-
\Magento\Swatches\Helper\Data $swatchHelper,
72-
\Magento\Swatches\Helper\Media $mediaHelper,
73-
array $data = []
83+
Data $swatchHelper,
84+
Media $mediaHelper,
85+
array $data = [],
86+
?Pager $htmlPagerBlock = null
7487
) {
7588
$this->eavAttribute = $eavAttribute;
7689
$this->layerAttribute = $layerAttribute;
7790
$this->swatchHelper = $swatchHelper;
7891
$this->mediaHelper = $mediaHelper;
92+
$this->htmlPagerBlock = $htmlPagerBlock ?? ObjectManager::getInstance()->get(Pager::class);
7993

8094
parent::__construct($context, $data);
8195
}
8296

8397
/**
98+
* Set filter and attribute objects
99+
*
84100
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
101+
*
85102
* @return $this
86103
* @throws \Magento\Framework\Exception\LocalizedException
87104
*/
@@ -94,6 +111,8 @@ public function setSwatchFilter(\Magento\Catalog\Model\Layer\Filter\AbstractFilt
94111
}
95112

96113
/**
114+
* Get attribute swatch data
115+
*
97116
* @return array
98117
*/
99118
public function getSwatchData()
@@ -114,30 +133,46 @@ public function getSwatchData()
114133
$attributeOptionIds = array_keys($attributeOptions);
115134
$swatches = $this->swatchHelper->getSwatchesByOptionsId($attributeOptionIds);
116135

117-
$data = [
136+
return [
118137
'attribute_id' => $this->eavAttribute->getId(),
119138
'attribute_code' => $this->eavAttribute->getAttributeCode(),
120139
'attribute_label' => $this->eavAttribute->getStoreLabel(),
121140
'options' => $attributeOptions,
122141
'swatches' => $swatches,
123142
];
124-
125-
return $data;
126143
}
127144

128145
/**
146+
* Build filter option url
147+
*
129148
* @param string $attributeCode
130149
* @param int $optionId
150+
*
131151
* @return string
132152
*/
133153
public function buildUrl($attributeCode, $optionId)
134154
{
135-
$query = [$attributeCode => $optionId];
136-
return $this->_urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);
155+
$query = [
156+
$attributeCode => $optionId,
157+
// exclude current page from urls
158+
$this->htmlPagerBlock->getPageVarName() => null
159+
];
160+
161+
return $this->_urlBuilder->getUrl(
162+
'*/*/*',
163+
[
164+
'_current' => true,
165+
'_use_rewrite' => true,
166+
'_query' => $query
167+
]
168+
);
137169
}
138170

139171
/**
172+
* Get view data for option with no results
173+
*
140174
* @param Option $swatchOption
175+
*
141176
* @return array
142177
*/
143178
protected function getUnusedOption(Option $swatchOption)
@@ -150,8 +185,11 @@ protected function getUnusedOption(Option $swatchOption)
150185
}
151186

152187
/**
188+
* Get option data if visible
189+
*
153190
* @param FilterItem[] $filterItems
154191
* @param Option $swatchOption
192+
*
155193
* @return array
156194
*/
157195
protected function getFilterOption(array $filterItems, Option $swatchOption)
@@ -166,8 +204,11 @@ protected function getFilterOption(array $filterItems, Option $swatchOption)
166204
}
167205

168206
/**
207+
* Get view data for option
208+
*
169209
* @param FilterItem $filterItem
170210
* @param Option $swatchOption
211+
*
171212
* @return array
172213
*/
173214
protected function getOptionViewData(FilterItem $filterItem, Option $swatchOption)
@@ -187,15 +228,20 @@ protected function getOptionViewData(FilterItem $filterItem, Option $swatchOptio
187228
}
188229

189230
/**
231+
* Check if option should be visible
232+
*
190233
* @param FilterItem $filterItem
234+
*
191235
* @return bool
192236
*/
193237
protected function isOptionVisible(FilterItem $filterItem)
194238
{
195-
return $this->isOptionDisabled($filterItem) && $this->isShowEmptyResults() ? false : true;
239+
return !($this->isOptionDisabled($filterItem) && $this->isShowEmptyResults());
196240
}
197241

198242
/**
243+
* Check if attribute values should be visible with no results
244+
*
199245
* @return bool
200246
*/
201247
protected function isShowEmptyResults()
@@ -204,7 +250,10 @@ protected function isShowEmptyResults()
204250
}
205251

206252
/**
253+
* Check if option should be disabled
254+
*
207255
* @param FilterItem $filterItem
256+
*
208257
* @return bool
209258
*/
210259
protected function isOptionDisabled(FilterItem $filterItem)
@@ -213,8 +262,11 @@ protected function isOptionDisabled(FilterItem $filterItem)
213262
}
214263

215264
/**
265+
* Retrieve filter item by id
266+
*
216267
* @param FilterItem[] $filterItems
217268
* @param integer $id
269+
*
218270
* @return bool|FilterItem
219271
*/
220272
protected function getFilterItemById(array $filterItems, $id)
@@ -228,14 +280,15 @@ protected function getFilterItemById(array $filterItems, $id)
228280
}
229281

230282
/**
283+
* Get swatch image path
284+
*
231285
* @param string $type
232286
* @param string $filename
287+
*
233288
* @return string
234289
*/
235290
public function getSwatchPath($type, $filename)
236291
{
237-
$imagePath = $this->mediaHelper->getSwatchAttributeImage($type, $filename);
238-
239-
return $imagePath;
292+
return $this->mediaHelper->getSwatchAttributeImage($type, $filename);
240293
}
241294
}

app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddTextSwatchToProductActionGroup.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<argument name="option2" defaultValue="textSwatchOption2" type="string"/>
2020
<argument name="option3" defaultValue="textSwatchOption3" type="string"/>
2121
<argument name="usedInProductListing" defaultValue="No" type="string"/>
22+
<argument name="usedInLayeredNavigation" defaultValue="No" type="string"/>
2223
</arguments>
2324

2425
<amOnPage url="{{ProductAttributePage.url}}" stepKey="goToNewProductAttributePage"/>
@@ -41,6 +42,7 @@
4142
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/>
4243
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" stepKey="waitForTabSwitch"/>
4344
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" userInput="{{usedInProductListing}}" stepKey="useInProductListing"/>
45+
<selectOption selector="{{AttributePropertiesSection.useInLayeredNavigation}}" userInput="{{usedInLayeredNavigation}}" stepKey="useInLayeredNavigation"/>
4446
<click selector="{{AttributePropertiesSection.SaveAndEdit}}" stepKey="clickSave"/>
4547
</actionGroup>
4648
</actionGroups>

0 commit comments

Comments
 (0)