Skip to content

Commit f1730c5

Browse files
Merge branch '1.1-develop' of github.com:magento/magento2-page-builder into PB-77
2 parents 77ff997 + 5c43245 commit f1730c5

File tree

13 files changed

+467
-21
lines changed

13 files changed

+467
-21
lines changed

app/code/Magento/PageBuilder/Model/Catalog/Sorting/SimpleOption.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ class SimpleOption implements OptionInterface
3737

3838
/**
3939
* @param string $label
40-
* @param string $sortDirection
41-
* @param string $attributeField
40+
* @param string|null $sortDirection
41+
* @param string|null $attributeField
4242
* @param string|null $secondarySortDirection
4343
*/
4444
public function __construct(
4545
string $label,
46-
string $sortDirection,
47-
string $attributeField,
46+
string $sortDirection = null,
47+
string $attributeField = null,
4848
string $secondarySortDirection = null
4949
) {
5050
$this->label = $label;
@@ -59,10 +59,11 @@ public function __construct(
5959
public function sort(
6060
\Magento\Catalog\Model\ResourceModel\Product\Collection $collection
6161
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
62-
$collection->getSelect()->reset(Select::ORDER);
63-
$collection->addAttributeToSort($this->attributeField, $this->sortDirection);
64-
$collection->addAttributeToSort('entity_id', $this->secondarySortDirection);
65-
62+
if ($this->attributeField && $this->sortDirection) {
63+
$collection->getSelect()->reset(Select::ORDER);
64+
$collection->addAttributeToSort($this->attributeField, $this->sortDirection);
65+
$collection->addAttributeToSort('entity_id', $this->secondarySortDirection);
66+
}
6667
return $collection;
6768
}
6869

app/code/Magento/PageBuilder/Plugin/Catalog/Block/Product/ProductsListPlugin.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public function afterCreateCollection(
6060
\Magento\CatalogWidget\Block\Product\ProductsList $subject,
6161
\Magento\Catalog\Model\ResourceModel\Product\Collection $result
6262
) {
63-
$categoryId = $subject->getData('category_ids');
63+
$conditionOption = $subject->getData('condition_option');
64+
$categoryId = $conditionOption === 'category_ids' ? $subject->getData('condition_option_value') : null;
6465
$sortOption = $subject->getData('sort_order');
6566

6667
$this->stock->addIsInStockFilterToCollection($result);
@@ -93,6 +94,7 @@ public function afterCreateCollection(
9394
public function afterGetCacheKeyInfo(\Magento\CatalogWidget\Block\Product\ProductsList $subject, array $cacheKeys)
9495
{
9596
$cacheKeys[] = $subject->getData('sort_order');
97+
$cacheKeys[] = $subject->getData('condition_option');
9698
return $cacheKeys;
9799
}
98100

@@ -105,7 +107,8 @@ public function afterGetCacheKeyInfo(\Magento\CatalogWidget\Block\Product\Produc
105107
*/
106108
public function afterGetIdentities(\Magento\CatalogWidget\Block\Product\ProductsList $subject, array $result)
107109
{
108-
$categoryId = $subject->getData('category_ids');
110+
$conditionOption = $subject->getData('condition_option');
111+
$categoryId = $conditionOption === 'category_ids' ? $subject->getData('condition_option_value') : null;
109112
$sortOption = $subject->getData('sort_order');
110113

111114
if (!empty($categoryId) && $sortOption === 'position') {

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeProductsActionGroup.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<argument name="property" defaultValue="PageBuilderProductsSelectCategoryDropDown"/>
6161
<argument name="category" type="string"/>
6262
</arguments>
63+
<waitForPageLoad stepKey="waitForPageLoad"/>
6364
<waitForElementVisible time="2" selector="{{EditPanelForm.panelMultiSelectFieldControl(property.section, property.fieldName)}}" stepKey="waitForMultiSelectFieldVisible"/>
6465
<click selector="{{EditPanelForm.panelMultiSelectFieldControl(property.section, property.fieldName)}}" stepKey="clickMultiSelectField"/>
6566
<waitForElementVisible selector="{{EditPanelForm.panelMultiSelectFieldControlInput(property.section, property.fieldName)}}" stepKey="waitForSearchField"/>
@@ -70,6 +71,17 @@
7071
<waitForElementNotVisible selector="{{EditPanelForm.panelMultiSelectFieldControlInput(property.section, property.fieldName)}}" stepKey="waitForSearchFieldNotVisible"/>
7172
<see selector="{{EditPanelForm.panelMultiSelectFieldControl(property.section, property.fieldName)}}" userInput="{{category}}" stepKey="seeResultInField"/>
7273
</actionGroup>
74+
<actionGroup name="addSKUsToSelectProductsBySKU">
75+
<arguments>
76+
<argument name="property" defaultValue="PageBuilderProductsEnterSKUsInput"/>
77+
<argument name="SKUs" type="string"/>
78+
</arguments>
79+
<waitForPageLoad stepKey="waitForPageLoad"/>
80+
<waitForElement time="2" selector="{{EditPanelForm.panelFieldControl(property.section, property.fieldName)}}" stepKey="waitForElementVisible"/>
81+
<see userInput="{{property.name}}" selector="{{EditPanelForm.panelFieldLabel(property.section, property.fieldName, property.section, property.name)}}" stepKey="seePropertyLabel"/>
82+
<fillField selector="{{EditPanelForm.panelFieldControl(property.section, property.fieldName)}}" userInput="{{SKUs}}" stepKey="fillPropertyField"/>
83+
<click selector="{{EditPanelForm.panelFieldLabel(property.section, property.fieldName, property.section, property.name)}}" stepKey="clickOnFieldLabel"/>
84+
</actionGroup>
7385
<actionGroup name="addConditionToProductConditions">
7486
<arguments>
7587
<argument name="conditionType" defaultValue="PageBuilderProductsConditionCategory"/>

app/code/Magento/PageBuilder/Test/Mftf/Data/ProductsData.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
<data key="fieldName">condition_option</data>
3838
<data key="value">category_ids</data>
3939
</entity>
40+
<entity name="PageBuilderProductsSelectProductsBySKU" type="pagebuilder_select_products_by_types">
41+
<data key="name">Select Products By</data>
42+
<data key="section">general</data>
43+
<data key="fieldName">condition_option</data>
44+
<data key="value">sku</data>
45+
</entity>
4046
<entity name="PageBuilderProductsSelectProductsByCondition" type="pagebuilder_select_products_by_types">
4147
<data key="name">Select Products By</data>
4248
<data key="section">general</data>
@@ -49,6 +55,12 @@
4955
<data key="section">general</data>
5056
<data key="fieldName">category_ids</data>
5157
</entity>
58+
<!-- SKU -->
59+
<entity name="PageBuilderProductsEnterSKUsInput" type="pagebuilder_products_sorting_types">
60+
<data key="name">Product SKUs</data>
61+
<data key="section">sku</data>
62+
<data key="fieldName">sku</data>
63+
</entity>
5264
<!-- Conditions -->
5365
<entity name="PageBuilderProductsConditionCombination" type="pagebuilder_products_condition_types">
5466
<data key="name">Conditions Combination</data>
@@ -85,6 +97,12 @@
8597
<data key="fieldName">sort_order</data>
8698
<data key="value">position</data>
8799
</entity>
100+
<entity name="PageBuilderProductsSortBySKUPosition" type="pagebuilder_products_sorting_types">
101+
<data key="name">Sort By</data>
102+
<data key="section">general</data>
103+
<data key="fieldName">sort_order</data>
104+
<data key="value">position_by_sku</data>
105+
</entity>
88106
<!-- Number of Products to Display: Grid Appearance -->
89107
<entity name="PageBuilderProductsCountPropertyOne" type="pagebuilder_content_type">
90108
<data key="name">Number of Products to Display</data>

0 commit comments

Comments
 (0)