Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 9f006e0

Browse files
authored
Merge pull request #2877 from magento-tsg/2.2-develop-pr35
Bugs: - MAGETWO-91372 Can't place order with Braintree Credit Card from Admin with Basic Fraud Protection - MAGETWO-91412 Wrong order status on registered checkout within Braintree Credit Card from Storefront with Signifyd Declined Guarantee - MAGETWO-73638 Product "Use Default Value" checkbox for an attributes are unchecked for the new website scope - MAGETWO-87966 Incorrect tax presented on checkout page - MAGETWO-86104 Restricted admin cannot add attribute to product
2 parents 45a7e0c + bab64fc commit 9f006e0

29 files changed

+494
-68
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ private function handleImageRemoveError($postData, $productId)
216216
/**
217217
* Do copying data to stores
218218
*
219+
* If the 'copy_from' field is not specified in the input data,
220+
* the store fallback mechanism will automatically take the admin store's default value.
221+
*
219222
* @param array $data
220223
* @param int $productId
221224
* @return void
@@ -227,15 +230,17 @@ protected function copyToStores($data, $productId)
227230
if (isset($data['product']['website_ids'][$websiteId])
228231
&& (bool)$data['product']['website_ids'][$websiteId]) {
229232
foreach ($group as $store) {
230-
$copyFrom = (isset($store['copy_from'])) ? $store['copy_from'] : 0;
231-
$copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0;
232-
if ($copyTo) {
233-
$this->_objectManager->create(\Magento\Catalog\Model\Product::class)
234-
->setStoreId($copyFrom)
235-
->load($productId)
236-
->setStoreId($copyTo)
237-
->setCopyFromView(true)
238-
->save();
233+
if (isset($store['copy_from'])) {
234+
$copyFrom = $store['copy_from'];
235+
$copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0;
236+
if ($copyTo) {
237+
$this->_objectManager->create(\Magento\Catalog\Model\Product::class)
238+
->setStoreId($copyFrom)
239+
->load($productId)
240+
->setStoreId($copyTo)
241+
->setCopyFromView(true)
242+
->save();
243+
}
239244
}
240245
}
241246
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductCustomizableOptionsSection">
1212
<element name="checkIfCustomizableOptionsTabOpen" type="text" selector="//span[text()='Customizable Options']/parent::strong/parent::*[@data-state-collapsible='closed']"/>
13-
<element name="customezableOptions" type="text" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Customizable Options']"/>
13+
<element name="customezableOptions" type="text" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Customizable Options']" timeout="30"/>
1414
<element name="useDefaultOptionTitle" type="text" selector="[data-index='options'] tr.data-row [data-index='title'] [name^='options_use_default']"/>
1515
<element name="useDefaultOptionValueTitleByIndex" type="text" selector="[data-index='options'] [data-index='values'] tr[data-repeat-index='{{var1}}'] [name^='options_use_default']" parameterized="true"/>
1616
<element name="addOptionBtn" type="button" selector="button[data-index='button_add']"/>
@@ -22,4 +22,4 @@
2222
<element name="fillOptionValuePrice" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//span[text()='Price']/parent::label/parent::div//div[@class='admin__control-addon']/input" parameterized="true"/>
2323
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//span[text()='Price Type']/parent::label/parent::div//select" parameterized="true"/>
2424
</section>
25-
</sections>
25+
</sections>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
<element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input"/>
1414
<element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/>
1515
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
16+
<element name="productNameUseDefault" type="checkbox" selector="input[name='use_default[name]']"/>
1617
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
1718
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
19+
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
1820
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
1921
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
22+
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
2023
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
2124
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
2225
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']"/>
@@ -29,6 +32,7 @@
2932
<element name="divByDataIndex" type="input" selector="div[data-index='{{var}}']" parameterized="true"/>
3033
<element name="attributeSetSearchCount" type="text" selector="div[data-index='attribute_set_id'] .admin__action-multiselect-search-count"/>
3134
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
35+
<element name="addAttributeBtn" type="button" selector="#addAttribute"/>
3236
</section>
3337
<section name="ProductInWebsitesSection">
3438
<element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/>
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AdminMultipleWebsitesUseDefaultValuesTest">
12+
<annotations>
13+
<title value="Use Default Value checkboxes should be checked for new website scope"/>
14+
<description value="Use Default Value checkboxes for product attribute should be checked for new website scope"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="MAGETWO-92990"/>
17+
<group value="catalog"/>
18+
</annotations>
19+
<after>
20+
<deleteData url="V1/products/{{_defaultProduct.sku}}" stepKey="deleteProduct"/>
21+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite">
22+
<argument name="websiteName" value="Second Website"/>
23+
</actionGroup>
24+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
25+
</after>
26+
<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>
27+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createAdditionalWebsite">
28+
<argument name="newWebsiteName" value="Second Website"/>
29+
<argument name="websiteCode" value="second_website"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStoreGroup">
32+
<argument name="website" value="Second Website"/>
33+
<argument name="storeGroupName" value="Second Store"/>
34+
<argument name="storeGroupCode" value="second_store"/>
35+
</actionGroup>
36+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStore">
37+
<argument name="storeGroup" value="secondStoreGroup"/>
38+
<argument name="customStore" value="secondStore"/>
39+
</actionGroup>
40+
41+
<!--Create a Simple Product -->
42+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
43+
<waitForPageLoad time="30" stepKey="waitForProductsGridPageLoad"/>
44+
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
45+
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
46+
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillProductName"/>
47+
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillProductSKU"/>
48+
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillProductPrice"/>
49+
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillProductQuantity"/>
50+
51+
<!-- Add product to second website and save the product -->
52+
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsites"/>
53+
<click selector="{{ProductInWebsitesSection.website('Second Website')}}" stepKey="selectSecondWebsite"/>
54+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/>
55+
<waitForLoadingMaskToDisappear stepKey="waitForProductPageSave"/>
56+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
57+
58+
<!-- switch to the second store view -->
59+
<click selector="{{AdminProductFormActionSection.changeStoreButton}}" stepKey="clickStoreviewSwitcher"/>
60+
<click selector="{{AdminProductFormActionSection.selectStoreView('Second Store View')}}" stepKey="chooseStoreView"/>
61+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="acceptStoreSwitchingMessage"/>
62+
<see userInput="Second Store View" selector="{{AdminMainActionsSection.storeSwitcher}}" stepKey="seeNewStoreViewName"/>
63+
64+
<!-- Check if Use Default Value checkboxes are checked -->
65+
<seeCheckboxIsChecked selector="{{AdminProductFormSection.productStatusUseDefault}}" stepKey="seeProductStatusCheckboxChecked"/>
66+
<seeCheckboxIsChecked selector="{{AdminProductFormSection.productNameUseDefault}}" stepKey="seeProductNameCheckboxChecked"/>
67+
<seeCheckboxIsChecked selector="{{AdminProductFormSection.productTaxClassUseDefault}}" stepKey="seeTaxClassCheckboxChecked"/>
68+
<seeCheckboxIsChecked selector="{{AdminProductFormSection.visibilityUseDefault}}" stepKey="seeVisibilityCheckboxChecked"/>
69+
</test>
70+
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,30 @@
2121

2222
<after>
2323
<actionGroup ref="ResetWebUrlOptions" stepKey="resetUrlOption"/>
24-
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"/>
25-
26-
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
24+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite">
25+
<argument name="websiteName" value="Second Website"/>
26+
</actionGroup>
27+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
2728
</after>
2829
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2930
<actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/>
30-
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="addnewWebsite"/>
31-
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="addNewStoreGroup"/>
32-
33-
<!--Create Store view -->
34-
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/>
35-
<waitForPageLoad time="30" stepKey="waitForStoreViewGridPageLoad" />
36-
<click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/>
37-
<waitForPageLoad stepKey="waitForProductPageLoad"/>
38-
<selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/>
39-
<fillField userInput="Second Store View" selector="{{AdminNewStoreSection.storeNameTextField}}" stepKey="fillStoreViewName"/>
40-
<fillField userInput="second_store_view" selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="fillStoreViewCode"/>
41-
<selectOption userInput="1" selector="{{AdminNewStoreSection.statusDropdown}}" stepKey="enableStoreViewStatus"/>
42-
<click selector="{{AdminStoresMainActionsSection.saveButton}}" stepKey="clickStoreViewSaveButton"/>
43-
<waitForElementVisible selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" stepKey="waitForAcceptNewStoreViewCreationModal" />
44-
<conditionalClick selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" dependentSelector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" visible="true" stepKey="AcceptNewStoreViewCreation"/>
45-
<waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReolad"/>
46-
<see userInput="You saved the store view." stepKey="seeSaveMessage" />
31+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="addnewWebsite">
32+
<argument name="newWebsiteName" value="Second Website"/>
33+
<argument name="websiteCode" value="second_website"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStoreGroup">
36+
<argument name="website" value="Second Website"/>
37+
<argument name="storeGroupName" value="Second Store"/>
38+
<argument name="storeGroupCode" value="second_store"/>
39+
</actionGroup>
40+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStore">
41+
<argument name="storeGroup" value="secondStoreGroup"/>
42+
<argument name="customStore" value="secondStore"/>
43+
</actionGroup>
4744

4845
<!--Create a Simple Product with Custom Options -->
4946
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
47+
<waitForPageLoad time="30" stepKey="waitForProductsGridPageLoad"/>
5048
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
5149
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
5250
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
@@ -89,6 +87,5 @@
8987

9088
<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection"/>
9189
<seeNumberOfElements selector=".admin__dynamic-rows[data-index='values'] tr.data-row" userInput="3" stepKey="see4RowsOfOptions"/>
92-
9390
</test>
9491
</tests>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Checkout\Plugin\Model\Quote;
9+
10+
use Magento\Quote\Model\Quote;
11+
12+
/**
13+
* Clear quote addresses after all items were removed.
14+
*/
15+
class ResetQuoteAddresses
16+
{
17+
/**
18+
* @param Quote $quote
19+
* @param Quote $result
20+
* @param mixed $itemId
21+
*
22+
* @return Quote
23+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
24+
*/
25+
public function afterRemoveItem(Quote $quote, Quote $result, $itemId): Quote
26+
{
27+
if (empty($result->getAllVisibleItems())) {
28+
foreach ($result->getAllAddresses() as $address) {
29+
$result->removeAddress($address->getId());
30+
}
31+
}
32+
33+
return $result;
34+
}
35+
}

app/code/Magento/Checkout/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@
4949
</argument>
5050
</arguments>
5151
</type>
52+
<type name="Magento\Quote\Model\Quote">
53+
<plugin name="clear_addresses_after_product_delete" type="Magento\Checkout\Plugin\Model\Quote\ResetQuoteAddresses"/>
54+
</type>
5255
</config>

app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="AdminCreateNewStoreGroupActionGroup">
12+
<arguments>
13+
<argument name="website" type="string"/>
14+
<argument name="storeGroupName" type="string"/>
15+
<argument name="storeGroupCode" type="string"/>
16+
</arguments>
1217
<amOnPage url="{{AdminSystemStoreGroupPage.url}}" stepKey="navigateToNewStoreView"/>
1318
<waitForPageLoad stepKey="waitForPageLoad1" />
1419
<!--Create Store group -->
15-
<selectOption selector="{{AdminNewStoreGroupSection.storeGrpWebsiteDropdown}}" userInput="Second Website" stepKey="selectWebsite" />
16-
<fillField selector="{{AdminNewStoreGroupSection.storeGrpNameTextField}}" userInput="Second Store" stepKey="enterStoreGroupName" />
17-
<fillField selector="{{AdminNewStoreGroupSection.storeGrpCodeTextField}}" userInput="second_store" stepKey="enterStoreGroupCode" />
20+
<selectOption selector="{{AdminNewStoreGroupSection.storeGrpWebsiteDropdown}}" userInput="{{website}}" stepKey="selectWebsite" />
21+
<fillField selector="{{AdminNewStoreGroupSection.storeGrpNameTextField}}" userInput="{{storeGroupName}}" stepKey="enterStoreGroupName" />
22+
<fillField selector="{{AdminNewStoreGroupSection.storeGrpCodeTextField}}" userInput="{{storeGroupCode}}" stepKey="enterStoreGroupCode" />
1823
<selectOption selector="{{AdminNewStoreGroupSection.storeRootCategoryDropdown}}" userInput="Default Category" stepKey="chooseRootCategory" />
1924
<click selector="{{AdminStoreGroupActionsSection.saveButton}}" stepKey="clickSaveStoreGroup" />
2025
<waitForElementVisible selector="{{AdminStoresGridSection.storeGrpFilterTextField}}" stepKey="waitForStoreGridReload"/>

app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="AdminCreateWebsiteActionGroup">
12+
<arguments>
13+
<argument name="newWebsiteName" type="string"/>
14+
<argument name="websiteCode" type="string"/>
15+
</arguments>
1216
<amOnPage url="{{AdminSystemStoreWebsitePage.url}}" stepKey="navigateToNewWebsitePage"/>
1317
<waitForPageLoad stepKey="waitForStoresPageLoad"/>
1418
<!--Create Website-->
15-
<fillField selector="{{AdminNewWebsiteSection.name}}" userInput="Second Website" stepKey="enterWebsiteName" />
16-
<fillField selector="{{AdminNewWebsiteSection.code}}" userInput="second_website" stepKey="enterWebsiteCode" />
19+
<fillField selector="{{AdminNewWebsiteSection.name}}" userInput="{{newWebsiteName}}" stepKey="enterWebsiteName" />
20+
<fillField selector="{{AdminNewWebsiteSection.code}}" userInput="{{websiteCode}}" stepKey="enterWebsiteCode" />
1721
<click selector="{{AdminNewWebsiteActionsSection.saveWebsite}}" stepKey="clickSaveWebsite" />
1822
<waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/>
1923
<see userInput="You saved the website." stepKey="seeSavedMessage" />

0 commit comments

Comments
 (0)