Skip to content

Commit 87ca6b9

Browse files
Merge remote-tracking branch 'origin/2.4-develop' into MC-32546
2 parents 91580a4 + 2130fe0 commit 87ca6b9

File tree

286 files changed

+9296
-4537
lines changed

Some content is hidden

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

286 files changed

+9296
-4537
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If you are a new GitHub user, we recommend that you create your own [free github
3131
This will allow you to collaborate with the Magento 2 development team, fork the Magento 2 project and send pull requests.
3232

3333
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
34-
2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
34+
2. Review the [Contributor License Agreement](https://opensource.adobe.com/cla.html) if this is your first time contributing.
3535
3. Create and test your work.
3636
4. Fork the Magento 2 repository according to the [Fork A Repository instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create A Pull Request instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#pull_request).
3737
5. Once your contribution is received the Magento 2 development team will review the contribution and collaborate with you as needed.

app/code/Magento/Braintree/Test/Mftf/Test/CretateAdminOrderWithOnlinePaymentIncludingTaxAndDiscountTest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</after>
7575

7676
<!-- Create a cart price rule with 10% discount for whole cart -->
77-
<click selector="{{AdminMenuSection.marketing}}" stepKey="clickOnMarketing" />
77+
<click selector="{{AdminMenuSection.marketing}}" stepKey="clickOnMarketing"/>
7878
<waitForPageLoad stepKey="waitForMarketing"/>
7979
<click selector="{{CartPriceRulesSubmenuSection.cartPriceRules}}" stepKey="clickOnCartPriceRules"/>
8080
<waitForPageLoad stepKey="waitForCartPriceRules"/>
@@ -93,7 +93,9 @@
9393
<actionGroup ref="ChangeShippingTaxClassActionGroup" stepKey="changeShippingTaxClass"/>
9494

9595
<!--Adding Special price to product-->
96-
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct.id$$)}}" stepKey="openAdminProductEditPage"/>
96+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAdminProductEditPage">
97+
<argument name="productId" value="$$simpleProduct.id$$"/>
98+
</actionGroup>
9799
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPrice"/>
98100
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>
99101

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleProductToCartFromWishListPageTest.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@
5050
<requiredEntity createDataKey="bundleOption"/>
5151
<requiredEntity createDataKey="createSimpleProduct2"/>
5252
</createData>
53-
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="goToProductEditPage"/>
53+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToProductEditPage">
54+
<argument name="productId" value="$$createProduct.id$$"/>
55+
</actionGroup>
5456
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
5557
</before>
5658
<after>
5759
<!-- Delete created data -->
5860
<comment userInput="Delete created data" stepKey="commentDeleteCreatedData"/>
5961
<deleteData createDataKey="createCustomerViaTheStorefront" stepKey="deleteCustomerViaTheStorefront"/>
60-
<deleteData createDataKey="createProduct" stepKey="deleteProduct" />
62+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
6163
<!-- Log out -->
6264
<comment userInput="Log out" stepKey="commentLogOut"/>
6365
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
@@ -74,8 +76,8 @@
7476
<actionGroup ref="StorefrontCustomerAddProductToWishlistActionGroup" stepKey="addToWishlistProduct">
7577
<argument name="productVar" value="$$createProduct$$"/>
7678
</actionGroup>
77-
<moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName($$createProduct.name$$)}}" stepKey="moveMouseOverProduct" />
78-
<click selector="{{StorefrontCategoryProductSection.ProductAddToCartByName($$createProduct.name$$)}}" stepKey="clickAddToCart" />
79+
<moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName($$createProduct.name$$)}}" stepKey="moveMouseOverProduct"/>
80+
<click selector="{{StorefrontCategoryProductSection.ProductAddToCartByName($$createProduct.name$$)}}" stepKey="clickAddToCart"/>
7981
<waitForPageLoad stepKey="waitForProductBundlePage"/>
8082
<!-- See error message -->
8183
<comment userInput="See error message" stepKey="commentSeeErrorMessage"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCheckBundleProductOptionTierPricesTest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@
2727
<!-- Add tier prices to simple products -->
2828
<!-- Simple product 1 -->
2929
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
30-
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct1CreateBundleProduct.id$$)}}" stepKey="openAdminEditPageProduct1"/>
30+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAdminEditPageProduct1">
31+
<argument name="productId" value="$$simpleProduct1CreateBundleProduct.id$$"/>
32+
</actionGroup>
3133
<actionGroup ref="ProductSetAdvancedPricingActionGroup" stepKey="addTierPriceProduct1">
3234
<argument name="group" value="ALL GROUPS"/>
3335
<argument name="quantity" value="5"/>
3436
<argument name="price" value="Discount"/>
3537
<argument name="amount" value="50"/>
3638
</actionGroup>
3739
<!-- Simple product 2 -->
38-
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct2CreateBundleProduct.id$$)}}" stepKey="openAdminEditPageProduct2"/>
40+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAdminEditPageProduct2">
41+
<argument name="productId" value="$$simpleProduct2CreateBundleProduct.id$$"/>
42+
</actionGroup>
3943
<actionGroup ref="ProductSetAdvancedPricingActionGroup" stepKey="addTierPriceProduct2">
4044
<argument name="group" value="ALL GROUPS"/>
4145
<argument name="quantity" value="7"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontVerifyDynamicBundleProductPricesForCombinationOfOptionsTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
<!--Add special price to simple product-->
4242
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
43-
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct5.id$$)}}" stepKey="openAdminEditPage"/>
43+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAdminEditPage">
44+
<argument name="productId" value="$$simpleProduct5.id$$"/>
45+
</actionGroup>
4446
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPrice"/>
4547
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>
4648

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,31 @@
66
* Copyright © Magento, Inc. All rights reserved.
77
* See COPYING.txt for license details.
88
*/
9+
910
namespace Magento\BundleImportExport\Model\Import\Product\Type;
1011

11-
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
12-
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
13-
use Magento\Framework\App\ObjectManager;
1412
use Magento\Bundle\Model\Product\Price as BundlePrice;
1513
use Magento\Catalog\Model\Product\Type\AbstractType;
14+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
1615
use Magento\CatalogImportExport\Model\Import\Product;
16+
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
17+
use Magento\Framework\App\ObjectManager;
1718
use Magento\Framework\App\ResourceConnection;
1819
use Magento\Framework\EntityManager\MetadataPool;
1920
use Magento\Store\Model\StoreManagerInterface;
2021

2122
/**
22-
* Class Bundle
23+
* Import entity Bundle product type.
2324
*
24-
* @package Magento\BundleImportExport\Model\Import\Product\Type
2525
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2626
*/
2727
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
2828
{
29-
3029
/**
3130
* Delimiter before product option value.
3231
*/
3332
const BEFORE_OPTION_VALUE_DELIMITER = ';';
3433

35-
/**
36-
* Pair value separator.
37-
*/
3834
const PAIR_VALUE_SEPARATOR = '=';
3935

4036
/**
@@ -47,19 +43,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
4743
*/
4844
const VALUE_FIXED = 'fixed';
4945

50-
/**
51-
* Not fixed dynamic attribute.
52-
*/
5346
const NOT_FIXED_DYNAMIC_ATTRIBUTE = 'price_view';
5447

55-
/**
56-
* Selection price type fixed.
57-
*/
5848
const SELECTION_PRICE_TYPE_FIXED = 0;
5949

60-
/**
61-
* Selection price type percent.
62-
*/
6350
const SELECTION_PRICE_TYPE_PERCENT = 1;
6451

6552
/**
@@ -133,7 +120,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
133120
protected $_optionTypeMapping = [
134121
'dropdown' => 'select',
135122
'radiobutton' => 'radio',
136-
'checkbox' => 'checkbox',
123+
'checkbox' => 'checkbox',
137124
'multiselect' => 'multi',
138125
];
139126

@@ -543,7 +530,7 @@ protected function populateExistingSelections($existingOptions)
543530
? $this->_bundleFieldMapping[$origKey]
544531
: $origKey;
545532
if (
546-
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
533+
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
547534
) {
548535
$this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
549536
$existingSelection[$origKey];
@@ -616,6 +603,7 @@ protected function populateInsertOptionValues(array $optionIds): array
616603
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
617604
&& $assoc['parent_id'] == $entityId) {
618605
$option['parent_id'] = $entityId;
606+
//phpcs:ignore Magento2.Performance.ForeachArrayMerge
619607
$optionValues = array_merge(
620608
$optionValues,
621609
$this->populateOptionValueTemplate($option, $optionId)
@@ -675,10 +663,7 @@ private function insertParentChildRelations()
675663
$childIds = [];
676664
foreach ($options as $option) {
677665
foreach ($option['selections'] as $selection) {
678-
if (!isset($selection['parent_product_id'])) {
679-
if (!isset($this->_cachedSkuToProducts[$selection['sku']])) {
680-
continue;
681-
}
666+
if (isset($this->_cachedSkuToProducts[$selection['sku']])) {
682667
$childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
683668
}
684669
}
@@ -717,6 +702,8 @@ protected function _initAttributes()
717702
}
718703
}
719704
}
705+
706+
return $this;
720707
}
721708

722709
/**
@@ -735,17 +722,19 @@ protected function deleteOptionsAndSelections($productIds)
735722
$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
736723
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
737724
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
738-
$valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
739-
['bov' => $optionValueTable],
740-
['value_id']
741-
)->joinLeft(
742-
['bo' => $optionTable],
743-
'bo.option_id = bov.option_id',
744-
['option_id']
745-
)->where(
746-
'parent_id IN (?)',
747-
$productIds
748-
));
725+
$valuesIds = $this->connection->fetchAssoc(
726+
$this->connection->select()->from(
727+
['bov' => $optionValueTable],
728+
['value_id']
729+
)->joinLeft(
730+
['bo' => $optionTable],
731+
'bo.option_id = bov.option_id',
732+
['option_id']
733+
)->where(
734+
'parent_id IN (?)',
735+
$productIds
736+
)
737+
);
749738
$this->connection->delete(
750739
$optionValueTable,
751740
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="UpdateBundleProductViaImportTest">
12+
<annotations>
13+
<features value="Import/Export"/>
14+
<title value="Update Bundle product via import"/>
15+
<description
16+
value="Check that Bundle products are displaying on the storefront after updating product via importing CSV"/>
17+
<severity value="MAJOR"/>
18+
<group value="importExport"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
22+
</before>
23+
<after>
24+
<!-- Delete products created via import -->
25+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteBundleProduct">
26+
<argument name="sku" value="Bundle"/>
27+
</actionGroup>
28+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteSimpleProduct">
29+
<argument name="sku" value="Simple"/>
30+
</actionGroup>
31+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
32+
</after>
33+
34+
<!-- Create Bundle product via import -->
35+
<actionGroup ref="AdminImportProductsActionGroup" stepKey="adminImportProductsCreate">
36+
<argument name="behavior" value="Add/Update"/>
37+
<argument name="importFile" value="catalog_product_import_bundle.csv"/>
38+
<argument name="importNoticeMessage" value="Created: 2, Updated: 0, Deleted: 0"/>
39+
</actionGroup>
40+
<magentoCLI command="cache:flush" arguments="full_page" stepKey="flushCacheAfterCreate"/>
41+
<magentoCLI command="indexer:reindex" stepKey="indexerReindexAfterCreate"/>
42+
43+
<!-- Check Bundle product is visible on the storefront-->
44+
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="openCategoryPageAfterCreation">
45+
<argument name="categoryName" value="New"/>
46+
</actionGroup>
47+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup"
48+
stepKey="assertBundleProductInStockAfterCreation">
49+
<argument name="productName" value="Bundle"/>
50+
</actionGroup>
51+
52+
<!-- Update Bundle product via import -->
53+
<actionGroup ref="AdminImportProductsActionGroup" stepKey="adminImportProductsUpdate">
54+
<argument name="behavior" value="Add/Update"/>
55+
<argument name="importFile" value="catalog_product_import_bundle.csv"/>
56+
<argument name="importNoticeMessage" value="Created: 0, Updated: 2, Deleted: 0"/>
57+
</actionGroup>
58+
<magentoCLI command="cache:flush" arguments="full_page" stepKey="flushCacheAfterUpdate"/>
59+
<magentoCLI command="indexer:reindex" stepKey="indexerReindexAfterUpdate"/>
60+
61+
<!-- Check Bundle product is still visible on the storefront-->
62+
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="openCategoryPageAfterUpdate">
63+
<argument name="categoryName" value="New"/>
64+
</actionGroup>
65+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup"
66+
stepKey="assertBundleProductInStockAfterUpdate">
67+
<argument name="productName" value="Bundle"/>
68+
</actionGroup>
69+
</test>
70+
</tests>

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
17171717
// optimize if using cat index
17181718
$filters = $this->_productLimitationFilters;
17191719
if (isset($filters['category_id']) || isset($filters['visibility'])) {
1720-
$this->getSelect()->order('cat_index.position ' . $dir);
1720+
$this->getSelect()->order(['cat_index.position ' . $dir, 'e.entity_id ' . $dir]);
17211721
} else {
17221722
$this->getSelect()->order('e.entity_id ' . $dir);
17231723
}

0 commit comments

Comments
 (0)