Skip to content

Commit c651bf4

Browse files
Merge branch 'MC-36376' into 2.4-develop-com-pr15
2 parents 79d4344 + 1d7b207 commit c651bf4

File tree

112 files changed

+3885
-121
lines changed

Some content is hidden

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

112 files changed

+3885
-121
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminBundleProductSetAdvancedPricingActionGroup" extends="ProductSetAdvancedPricingActionGroup">
12+
<annotations>
13+
<description>Sets the provided Advanced Pricing on the Admin Bundle Product creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="priceView" type="string" defaultValue="Price Range"/>
17+
</arguments>
18+
<remove keyForRemoval="selectProductCustomGroupValue"/>
19+
<selectOption selector="{{AdminProductFormAdvancedPricingSection.bundleAdvancedPriceView}}" userInput="{{priceView}}" stepKey="selectPriceView" before="clickDoneButton"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminProductFormAdvancedPricingSection">
12+
<element name="bundleAdvancedPriceView" type="select" selector="div[data-index='advanced-pricing'] select[name='product[price_view]']"/>
13+
</section>
14+
</sections>

app/code/Magento/Bundle/Test/Mftf/Section/AdminProductFormBundleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<element name="bundleOptionXInputType" type="select" selector="[name='bundle_options[bundle_options][{{x}}][type]']" parameterized="true"/>
2121
<element name="bundleOptionXRequired" type="checkbox" selector="[name='bundle_options[bundle_options][{{x}}][required]']" parameterized="true"/>
2222
<element name="bundleOptionXProductYQuantity" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_qty]']" parameterized="true"/>
23+
<element name="bundleOptionXProductYPrice" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_price_value]']" parameterized="true"/>
2324
<element name="addProductsToOption" type="button" selector="[data-index='modal_set']" timeout="30"/>
2425
<element name="nthAddProductsToOption" type="button" selector="//tr[{{var}}]//button[@data-index='modal_set']" timeout="30" parameterized="true"/>
2526
<element name="bundlePriceType" type="select" selector="bundle_options[bundle_options][0][bundle_selections][0][selection_price_type]"/>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<element name="priceTo" type="text" selector=".product-info-price .price-to"/>
1414
<element name="minPrice" type="text" selector="span[data-price-type='minPrice']"/>
1515
<element name="maxPrice" type="text" selector="span[data-price-type='minPrice']"/>
16+
<element name="asLowAsFinalPrice" type="text" selector="div.price-box.price-final_price p.minimal-price > span.price-final_price span.price"/>
17+
<element name="fixedFinalPrice" type="text" selector="div.price-box.price-final_price > span.price-final_price span.price"/>
1618
<element name="productBundleOptionsCheckbox" type="checkbox" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{childName}}')]/../input" parameterized="true" timeout="30"/>
1719
</section>
1820
</sections>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="BundleProductWithDynamicTierPriceInCartTest" extends="BundleProductWithTierPriceWithFixedAndPercentOptionsInCartTest">
11+
<annotations>
12+
<stories value="Add bundle product to cart on storefront"/>
13+
<title value="Customer should get the right subtotal in cart when the bundle product with dynamic tier price added to the cart"/>
14+
<description value="Customer should be able to add bundle product with dynamic tier price to the cart and get the right price"/>
15+
<severity value="CRITICAL"/>
16+
</annotations>
17+
18+
<before>
19+
<createData entity="VirtualProduct" stepKey="createProductForBundleItem1">
20+
<field key="price">50.00</field>
21+
</createData>
22+
<createData entity="SimpleProduct2" stepKey="createProductForBundleItem2">
23+
<field key="price">100.00</field>
24+
</createData>
25+
</before>
26+
27+
<remove keyForRemoval="clickDynamicPriceSwitcher"/>
28+
<remove keyForRemoval="fillBundlePrice"/>
29+
<remove keyForRemoval="disableDynamicSku"/>
30+
<remove keyForRemoval="fillBundleOption1Price"/>
31+
<remove keyForRemoval="selectPercentPrice"/>
32+
<remove keyForRemoval="fillBundleOption2Price"/>
33+
<assertEquals message="ExpectedPrice" stepKey="assertBundleProductPrice">
34+
<actualResult type="variable">grabProductPrice</actualResult>
35+
<expectedResult type="string">$75.00</expectedResult>
36+
</assertEquals>
37+
<actionGroup ref="AssertSubTotalOnStorefrontMiniCartActionGroup" stepKey="assertSubTotalOnStorefrontMiniCart">
38+
<argument name="subTotal" value="$75.00"/>
39+
</actionGroup>
40+
</test>
41+
</tests>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="BundleProductWithOptionTierPriceInCartTest" extends="BundleProductWithTierPriceWithFixedAndPercentOptionsInCartTest">
11+
<annotations>
12+
<stories value="Add bundle product to cart on storefront"/>
13+
<title value="Customer should get the right subtotal in cart when the bundle product with tier price for sub-item added to the cart"/>
14+
<description value="Customer should be able to add bundle product with tier price for sub-item price to the cart and get the right price"/>
15+
<severity value="CRITICAL"/>
16+
</annotations>
17+
18+
<before>
19+
<createData entity="VirtualProduct" stepKey="createProductForBundleItem1">
20+
<field key="price">50.00</field>
21+
</createData>
22+
<createData entity="SimpleProduct2" stepKey="createProductForBundleItem2">
23+
<field key="price">100.00</field>
24+
</createData>
25+
<createData entity="TierProductPrice50PercentDiscount" stepKey="addTierPrice">
26+
<requiredEntity createDataKey="createProductForBundleItem2"/>
27+
</createData>
28+
</before>
29+
30+
<remove keyForRemoval="clickDynamicPriceSwitcher"/>
31+
<remove keyForRemoval="fillBundlePrice"/>
32+
<remove keyForRemoval="disableDynamicSku"/>
33+
<remove keyForRemoval="fillBundleOption1Price"/>
34+
<remove keyForRemoval="selectPercentPrice"/>
35+
<remove keyForRemoval="fillBundleOption2Price"/>
36+
<remove keyForRemoval="addProductTierPrice"/>
37+
<actionGroup ref="SaveProductFormActionGroup" after="addBundleOption2" stepKey="saveBundleProduct"/>
38+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.fixedFinalPrice}}" stepKey="grabProductPrice"/>
39+
<assertEquals message="ExpectedPrice" stepKey="assertBundleProductPrice">
40+
<actualResult type="variable">grabProductPrice</actualResult>
41+
<expectedResult type="string">$100.00</expectedResult>
42+
</assertEquals>
43+
<actionGroup ref="AssertSubTotalOnStorefrontMiniCartActionGroup" stepKey="assertSubTotalOnStorefrontMiniCart">
44+
<argument name="subTotal" value="$100.00"/>
45+
</actionGroup>
46+
</test>
47+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="BundleProductWithTierPriceWithFixedAndPercentOptionsInCartTest">
11+
<annotations>
12+
<features value="Bundle"/>
13+
<stories value="Add bundle product to cart on storefront"/>
14+
<title value="Customer should get the right subtotal in cart when the bundle product with tier price and bundle items with fixed and percent price added to the cart"/>
15+
<description value="Customer should be able to add bundle product with tier price and bundle items with fixed and percent price to the cart and get the right price"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-26543"/>
18+
<group value="bundle"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="SimpleProduct2" stepKey="createProductForBundleItem1">
24+
<field key="price">100.00</field>
25+
</createData>
26+
<createData entity="SimpleProduct2" stepKey="createProductForBundleItem2">
27+
<field key="price">100.00</field>
28+
</createData>
29+
<magentoCron groups="index" stepKey="runCronIndex"/>
30+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
31+
</before>
32+
33+
<after>
34+
<deleteData createDataKey="createProductForBundleItem1" stepKey="deleteProductForBundleItem1"/>
35+
<deleteData createDataKey="createProductForBundleItem2" stepKey="deleteProductForBundleItem2"/>
36+
<actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteBundle">
37+
<argument name="product" value="BundleProduct"/>
38+
</actionGroup>
39+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductsGridFilters"/>
40+
<waitForPageLoad stepKey="waitForClearProductsGridFilters"/>
41+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
42+
</after>
43+
44+
<amOnPage url="{{AdminProductCreatePage.url(BundleProduct.set, BundleProduct.type)}}" stepKey="goToBundleProductCreationPage"/>
45+
<waitForPageLoad stepKey="waitForBundleProductCreatePageToLoad"/>
46+
<click selector="{{AdminProductFormBundleSection.dynamicSkuToggle}}" stepKey="disableDynamicSku"/>
47+
<click selector="{{AdminProductFormBundleSection.dynamicPrice}}" stepKey="clickDynamicPriceSwitcher"/>
48+
<fillField selector="{{AdminProductFormBundleSection.priceField}}" userInput="100" stepKey="fillBundlePrice"/>
49+
<actionGroup ref="FillMainBundleProductFormActionGroup" stepKey="fillMainFieldsForBundle"/>
50+
<actionGroup ref="AddBundleOptionWithOneProductActionGroup" stepKey="addBundleOption1">
51+
<argument name="x" value="0"/>
52+
<argument name="n" value="1"/>
53+
<argument name="prodOneSku" value="$createProductForBundleItem1.sku$"/>
54+
<argument name="prodTwoSku" value=""/>
55+
<argument name="optionTitle" value="Option1"/>
56+
<argument name="inputType" value="checkbox"/>
57+
</actionGroup>
58+
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYPrice('0', '0')}}" userInput="100" stepKey="fillBundleOption1Price"/>
59+
<selectOption selector="{{AdminProductFormBundleSection.bundlePriceType}}" userInput="Percent" stepKey="selectPercentPrice"/>
60+
<actionGroup ref="AddBundleOptionWithOneProductActionGroup" stepKey="addBundleOption2">
61+
<argument name="x" value="1"/>
62+
<argument name="n" value="2"/>
63+
<argument name="prodOneSku" value="$createProductForBundleItem2.sku$"/>
64+
<argument name="prodTwoSku" value=""/>
65+
<argument name="optionTitle" value="Option2"/>
66+
<argument name="inputType" value="checkbox"/>
67+
</actionGroup>
68+
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYPrice('1', '0')}}" userInput="100" stepKey="fillBundleOption2Price"/>
69+
<scrollToTopOfPage stepKey="scrollToTopOfTheProductPage"/>
70+
<actionGroup ref="AdminBundleProductSetAdvancedPricingActionGroup" stepKey="addProductTierPrice">
71+
<argument name="quantity" value="1"/>
72+
<argument name="price" value="Discount"/>
73+
<argument name="amount" value="50"/>
74+
<argument name="priceView" value="As Low as"/>
75+
</actionGroup>
76+
<amOnPage url="{{StorefrontProductPage.url(BundleProduct.urlKey)}}" stepKey="goToStorefront"/>
77+
<waitForPageLoad stepKey="waitForStorefront"/>
78+
<!--Assert Bundle Product Price-->
79+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.asLowAsFinalPrice}}" stepKey="grabProductPrice"/>
80+
<assertEquals message="ExpectedPrice" stepKey="assertBundleProductPrice">
81+
<actualResult type="variable">grabProductPrice</actualResult>
82+
<expectedResult type="string">$150.00</expectedResult>
83+
</assertEquals>
84+
<actionGroup ref="StorefrontSelectCustomizeAndAddToTheCartButtonActionGroup" stepKey="clickOnCustomizeAndAddToCartButton"/>
85+
<actionGroup ref="StorefrontEnterProductQuantityAndAddToTheCartActionGroup" stepKey="enterProductQuantityAndAddToTheCart">
86+
<argument name="quantity" value="1"/>
87+
</actionGroup>
88+
<actionGroup ref="AssertSubTotalOnStorefrontMiniCartActionGroup" stepKey="assertSubTotalOnStorefrontMiniCart">
89+
<argument name="subTotal" value="$150.00"/>
90+
</actionGroup>
91+
</test>
92+
</tests>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@
7272
<data key="quantity">3</data>
7373
<var key="sku" entityType="product" entityKey="sku" />
7474
</entity>
75+
<entity name="TierProductPrice50PercentDiscount" type="catalogTierPrice">
76+
<data key="price">50</data>
77+
<data key="price_type">discount</data>
78+
<data key="website_id">0</data>
79+
<data key="customer_group">ALL GROUPS</data>
80+
<data key="quantity">1</data>
81+
<var key="sku" entityType="product" entityKey="sku" />
82+
</entity>
7583
</entities>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<section name="StorefrontProductActionSection">
1111
<element name="quantity" type="input" selector="#qty"/>
1212
<element name="addToCart" type="button" selector="#product-addtocart-button" timeout="60"/>
13+
<element name="addToCartEnabledWithTranslation" type="button" selector="button#product-addtocart-button[data-translate]:enabled" timeout="60"/>
1314
<element name="addToCartButtonTitleIsAdding" type="text" selector="//button/span[text()='Adding...']"/>
1415
<element name="addToCartButtonTitleIsAdded" type="text" selector="//button/span[text()='Added']"/>
1516
<element name="addToCartButtonTitleIsAddToCart" type="text" selector="//button/span[text()='Add to Cart']"/>

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
101101
}
102102

103103
if (!$searchCriteria->getSortOrders()) {
104-
$this->addDefaultSortOrder($searchCriteria, $isSearch);
104+
$this->addDefaultSortOrder($searchCriteria, $args, $isSearch);
105105
}
106106

107+
$this->addEntityIdSort($searchCriteria, $isSearch);
107108
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
108109

109110
$searchCriteria->setCurrentPage($args['currentPage']);
@@ -132,6 +133,25 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
132133
$this->addFilter($searchCriteria, 'visibility', $visibilityIds, 'in');
133134
}
134135

136+
/**
137+
* Add sort by Entity ID
138+
*
139+
* @param SearchCriteriaInterface $searchCriteria
140+
* @param bool $isSearch
141+
*/
142+
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, bool $isSearch): void
143+
{
144+
if ($isSearch) {
145+
return;
146+
}
147+
$sortOrderArray = $searchCriteria->getSortOrders();
148+
$sortOrderArray[] = $this->sortOrderBuilder
149+
->setField('_id')
150+
->setDirection(SortOrder::SORT_DESC)
151+
->create();
152+
$searchCriteria->setSortOrders($sortOrderArray);
153+
}
154+
135155
/**
136156
* Prepare price aggregation algorithm
137157
*
@@ -179,18 +199,32 @@ private function addFilter(
179199
* Sort by relevance DESC by default
180200
*
181201
* @param SearchCriteriaInterface $searchCriteria
202+
* @param array $args
182203
* @param bool $isSearch
183204
*/
184-
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, $isSearch = false): void
205+
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, array $args, $isSearch = false): void
185206
{
186-
$sortField = $isSearch ? 'relevance' : EavAttributeInterface::POSITION;
187-
$sortDirection = $isSearch ? SortOrder::SORT_DESC : SortOrder::SORT_ASC;
188-
$defaultSortOrder = $this->sortOrderBuilder
189-
->setField($sortField)
190-
->setDirection($sortDirection)
191-
->create();
207+
$defaultSortOrder = [];
208+
if ($isSearch) {
209+
$defaultSortOrder[] = $this->sortOrderBuilder
210+
->setField('relevance')
211+
->setDirection(SortOrder::SORT_DESC)
212+
->create();
213+
} else {
214+
$categoryIdFilter = isset($args['filter']['category_id']) ? $args['filter']['category_id'] : false;
215+
if ($categoryIdFilter) {
216+
if (!is_array($categoryIdFilter[array_key_first($categoryIdFilter)])
217+
|| count($categoryIdFilter[array_key_first($categoryIdFilter)]) <= 1
218+
) {
219+
$defaultSortOrder[] = $this->sortOrderBuilder
220+
->setField(EavAttributeInterface::POSITION)
221+
->setDirection(SortOrder::SORT_ASC)
222+
->create();
223+
}
224+
}
225+
}
192226

193-
$searchCriteria->setSortOrders([$defaultSortOrder]);
227+
$searchCriteria->setSortOrders($defaultSortOrder);
194228
}
195229

196230
/**

0 commit comments

Comments
 (0)