Skip to content

Commit ede902f

Browse files
authored
Merge branch '2.4-develop' into community_prs_march
2 parents dcf455e + b072f7b commit ede902f

File tree

61 files changed

+1662
-139
lines changed

Some content is hidden

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

61 files changed

+1662
-139
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Model\Category\Attribute\Backend;
18+
19+
class DefaultSortby extends Sortby
20+
{
21+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Setup\Patch\Data;
18+
19+
use Magento\Catalog\Setup\CategorySetup;
20+
use Magento\Catalog\Setup\CategorySetupFactory;
21+
use Magento\Framework\Setup\ModuleDataSetupInterface;
22+
use Magento\Framework\Setup\Patch\DataPatchInterface;
23+
use Magento\Framework\Setup\Patch\PatchInterface;
24+
25+
class UpdateDefaultSortyByBackendType implements DataPatchInterface
26+
{
27+
/**
28+
* @var ModuleDataSetupInterface
29+
*/
30+
private $moduleDataSetup;
31+
32+
/**
33+
* @var CategorySetupFactory
34+
*/
35+
private $categorySetupFactory;
36+
37+
/**
38+
* PatchInitial constructor.
39+
* @param ModuleDataSetupInterface $moduleDataSetup
40+
* @param CategorySetupFactory $categorySetupFactory
41+
*/
42+
public function __construct(
43+
ModuleDataSetupInterface $moduleDataSetup,
44+
CategorySetupFactory $categorySetupFactory
45+
) {
46+
$this->moduleDataSetup = $moduleDataSetup;
47+
$this->categorySetupFactory = $categorySetupFactory;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function apply(): UpdateDefaultSortyByBackendType
54+
{
55+
$mediaBackendModel = \Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby::class;
56+
/** @var CategorySetup $categorySetup */
57+
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
58+
$categorySetup->updateAttribute(
59+
'catalog_category',
60+
'default_sort_by',
61+
'backend_model',
62+
$mediaBackendModel
63+
);
64+
65+
return $this;
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public static function getDependencies()
72+
{
73+
return [];
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public function getAliases()
80+
{
81+
return [];
82+
}
83+
}

app/code/Magento/Catalog/Test/Fixture/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Category implements RevertibleDataFixtureInterface
2727
'include_in_menu' => true,
2828
'available_sort_by' => [],
2929
'custom_attributes' => [
30-
'default_sort_by' => ['name']
30+
'default_sort_by' => 'position'
3131
],
3232
'extension_attributes' => [],
3333
'created_at' => null,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminUpdateAttributeUsedForSortingInProductListingActionGroup">
12+
<annotations>
13+
<description>Admin selects the values for "Use For Sorting in Product Listing" for created attribute </description>
14+
</annotations>
15+
<arguments>
16+
<argument name="usedForSortingInProductListing" type="string" defaultValue="Yes"/>
17+
</arguments>
18+
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="navigateToStorefrontPropertiesTab"/>
19+
<waitForElementVisible selector="{{StorefrontPropertiesSection.PageTitle}}" stepKey="waitForStorefrontPropertiesTabLoad"/>
20+
<selectOption selector="{{StorefrontPropertiesSection.usedForSortingInProductListing}}" userInput="{{usedForSortingInProductListing}}" stepKey="setValueForSortingInProductListing"/>
21+
</actionGroup>
22+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertProductSortingBasedOnAttributesInStorefrontCategoryPageActionGroup">
12+
<annotations>
13+
<description>Goes to the Storefront page. Validates the sorting of products based on the attributes.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="product1" defaultValue="product"/>
17+
<argument name="product2" defaultValue="product"/>
18+
<argument name="sortBy" type="string"/>
19+
</arguments>
20+
<selectOption userInput="{{sortBy}}" selector="{{StorefrontCategoryTopToolbarSection.sortByDropdown}}" stepKey="selectSortBy"/>
21+
<waitForPageLoad stepKey="waitForPageLoadPostSelectingSortBy"/>
22+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.productInOrderDisplay('1',product1.name)}}" stepKey="assertsTheProductAtIndex1"/>
23+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.productInOrderDisplay('2',product2.name)}}" stepKey="assertsTheProductAtIndex2"/>
24+
</actionGroup>
25+
</actionGroups>

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,27 @@
443443
<data key="attribute_code">attribute</data>
444444
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabelForExportImport</requiredEntity>
445445
</entity>
446+
<!-- Product attributes for sorting in product listing as No -->
447+
<entity name="textAttributeWithNoProductSortListing" extends="newProductAttribute" type="ProductAttribute">
448+
<data key="used_for_sort_by">false</data>
449+
</entity>
450+
<entity name="dateAttributeWithNoProductSortListing" extends="productAttributeWysiwyg" type="ProductAttribute">
451+
<data key="frontend_input">date</data>
452+
<data key="used_for_sort_by">false</data>
453+
</entity>
454+
<entity name="yesNoAttributeWithNoProductSortListing" extends="productYesNoAttribute" type="ProductAttribute">
455+
<data key="used_for_sort_by">false</data>
456+
</entity>
457+
<entity name="dropdownAttributeWithNoProductSortListing" extends="productAttributeWithDropdownTwoOptions" type="ProductAttribute">
458+
<data key="used_for_sort_by">false</data>
459+
</entity>
460+
<entity name="multiSelectAttributeWithNoProductSortListing" extends="productDropDownAttribute" type="ProductAttribute">
461+
<data key="frontend_input">multiselect</data>
462+
<data key="used_for_sort_by">false</data>
463+
</entity>
464+
<entity name="priceAttributeWithNoProductSortListing" extends="newProductAttribute" type="ProductAttribute">
465+
<data key="frontend_input">price</data>
466+
<data key="used_for_sort_by">false</data>
467+
</entity>
446468
</entities>
469+

app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection/StorefrontPropertiesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="useForPromoRuleConditions" type="select" selector="#is_used_for_promo_rules"/>
1515
<element name="StorefrontPropertiesSectionToggle" type="button" selector="#front_fieldset-wrapper"/>
1616
<element name="visibleOnCatalogPagesOnStorefront" type="select" selector="#is_visible_on_front"/>
17+
<element name="usedForSortingInProductListing" type="select" selector="#used_for_sort_by"/>
1718
</section>
1819
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<element name="isComparableColumn" type="text" selector="//div[@id='attributeGrid']//td[contains(@class,'a-center col-is_comparable')]"/>
2626
<element name="addSelected" type="button" selector="//*[contains(text(),'Add Selected')]" timeout="30"/>
2727
<element name="deleteSpecificColorAttribute" type="button" selector="//input[@value='{{var}}']/../..//button[@class='action- scalable delete delete-option']" parameterized="true"/>
28+
<element name="attributeNameInGrid" type="text" selector="//td[contains(@class,'col-attribute_code') and contains(text(),'{{attribute_code}}')]/following-sibling::td[contains(@class,'col-frontend_label')]" parameterized="true"/>
2829
</section>
2930
</sections>
3031

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,9 @@
8888
<element name="btnAdvancedInventory" type="button" selector="//button//span[text()='Advanced Inventory']/.."/>
8989
<element name="saveCategory" type="button" selector="//button[@data-action='close-advanced-select']" timeout="30"/>
9090
<element name="attributeRequiredInputField" type="select" selector="//select[contains(@name, 'product[{{attributeCode}}]')]" parameterized="true"/>
91+
<element name="customTextAttribute" type="input" selector="//input[@name='product[{{attribute_code}}]']" parameterized="true"/>
92+
<element name="customSelectAttribute" type="select" selector="//select[@name='product[{{attribute_code}}]']" parameterized="true"/>
93+
<element name="customSwitcherAttribute" type="checkbox" selector="//input[@name='product[{{attribute_code}}]' and @value='{{checked_value}}']/parent::div[@data-role='switcher']" parameterized="true"/>
94+
9195
</section>
9296
</sections>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
<element name="outOfStockProductCategoryPage" type="text" selector="//div[@class='stock unavailable']//span[text()='Out of stock']"/>
4747
<element name="ListedProductAttributes" type="block" selector="//div[@aria-label='{{vs_attribute}}']//div[@aria-label='{{attribute_name}}']" parameterized="true"/>
4848
<element name="quickOrderLink" type="text" selector="//div[@class='panel header']//a[text()='Quick Order']" />
49+
<element name="sortByDropdownContent" type="select" selector="//select[@id='sorter']//option[contains(text(),'{{arg}}')]" parameterized="true"/>
50+
<element name="productInOrderDisplay" type="text" selector="//li[@class='item product product-item'][{{index}}]//a[@class='product-item-link' and contains(text(),'{{product_name}}')]" parameterized="true"/>
4951
</section>
5052
</sections>

0 commit comments

Comments
 (0)