Skip to content

Commit 0dfc189

Browse files
Merge remote-tracking branch 'remotes/github/MC-17014' into EPAM-PR-66
2 parents 6f03dd3 + 284e1b7 commit 0dfc189

File tree

6 files changed

+154
-6
lines changed

6 files changed

+154
-6
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@
422422
<waitForPageLoad stepKey="waitForPageOpened"/>
423423
<checkOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="selectWebsite"/>
424424
</actionGroup>
425+
<actionGroup name="unassignWebsiteFromProductActionGroup" extends="SelectProductInWebsitesActionGroup">
426+
<remove keyForRemoval="selectWebsite"/>
427+
<uncheckOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="unSelectWebsite" after="waitForPageOpened"/>
428+
</actionGroup>
425429

426430
<actionGroup name="AdminProductAddSpecialPrice">
427431
<annotations>

app/code/Magento/Config/Test/Mftf/Test/CheckingCountryDropDownWithOneAllowedCountryTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<createData entity="EnableAdminAccountAllowCountry" stepKey="setAllowedCountries"/>
2323
</before>
2424
<after>
25+
<magentoCLI stepKey="flushCache" command="cache:flush"/>
2526
<createData entity="DisableAdminAccountAllowCountry" stepKey="setDefaultValueForAllowCountries"/>
2627
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2728
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">

app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Weee\Model\Attribute\Backend\Weee;
89

910
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1112

13+
/**
14+
* Class with fixed product taxes.
15+
*/
1216
class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price
1317
{
1418
/**
@@ -62,10 +66,14 @@ public function __construct(
6266
}
6367

6468
/**
69+
* Get backend model name.
70+
*
6571
* @return string
72+
* phpcs:disable Magento2.Functions.StaticFunction
6673
*/
6774
public static function getBackendModelName()
6875
{
76+
// phpcs:enable Magento2.Functions.StaticFunction
6977
return \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class;
7078
}
7179

@@ -91,8 +99,10 @@ public function validate($object)
9199
$key1 = implode('-', [$tax['website_id'], $tax['country'], $state]);
92100
if (!empty($dup[$key1])) {
93101
throw new LocalizedException(
94-
__('Set unique country-state combinations within the same fixed product tax. '
95-
. 'Verify the combinations and try again.')
102+
__(
103+
'Set unique country-state combinations within the same fixed product tax. '
104+
. 'Verify the combinations and try again.'
105+
)
96106
);
97107
}
98108
$dup[$key1] = 1;
@@ -130,7 +140,7 @@ public function afterLoad($object)
130140
}
131141

132142
/**
133-
* {@inheritdoc}
143+
* @inheritdoc
134144
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
135145
* @SuppressWarnings(PHPMD.NPathComplexity)
136146
*/
@@ -170,7 +180,7 @@ public function afterSave($object)
170180
}
171181

172182
/**
173-
* {@inheritdoc}
183+
* @inheritdoc
174184
*/
175185
public function afterDelete($object)
176186
{
@@ -179,7 +189,7 @@ public function afterDelete($object)
179189
}
180190

181191
/**
182-
* {@inheritdoc}
192+
* @inheritdoc
183193
*/
184194
public function getTable()
185195
{

app/code/Magento/Weee/Test/Mftf/Section/AdminProductAddFPTValueSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
<element name="selectCountryForFPT" type="select" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[country]')])[last()]" parameterized="true"/>
1515
<element name="selectStateForFPT" type="select" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[state]')])[last()]" parameterized="true"/>
1616
<element name="setTaxValueForFPT" type="text" selector="(//input[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[value]')])[last()]" parameterized="true"/>
17+
<element name="setWebSiteForFPT" type="text" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[website_id]')])[last()]" parameterized="true"/>
18+
<element name="setWebSiteForFPTOption" type="text" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[website_id]')])/option[contains(text(), '{{website}}')]" parameterized="true"/>
1719
</section>
1820
</sections>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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="AdminFixedTaxValSavedForSpecificWebsiteTest">
12+
<annotations>
13+
<features value="Tax"/>
14+
<title value="Fixed Product Tax value is saved correctly for Specific Website"/>
15+
<description value="Fixed Product Tax value is saved correctly for Specific Website"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-17182"/>
18+
<useCaseId value=" MC-17014"/>
19+
<group value="tax"/>
20+
</annotations>
21+
<before>
22+
<!-- Create product attribute and add it to default attribute set />-->
23+
<comment userInput="Create product attribute and add it to default attribute set" stepKey="createAttrAndAddToDefaultAttrSet"/>
24+
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
25+
<createData entity="AddToDefaultSet" stepKey="addToDefaultAttributeSet">
26+
<requiredEntity createDataKey="createProductFPTAttribute"/>
27+
</createData>
28+
<!-- Create product, category and log in -->
29+
<comment userInput="Create product, category and log in" stepKey="createDataAndLogIn"/>
30+
<createData entity="ApiCategory" stepKey="createCategory"/>
31+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
32+
<requiredEntity createDataKey="createCategory"/>
33+
</createData>
34+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
35+
<!-- Create website, store and store view -->
36+
<comment userInput="Create website, store and store view" stepKey="createWebsite"/>
37+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createSecondWebsite">
38+
<argument name="newWebsiteName" value="{{NewWebSiteData.name}}"/>
39+
<argument name="websiteCode" value="{{NewWebSiteData.code}}"/>
40+
</actionGroup>
41+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createSecondStore">
42+
<argument name="website" value="{{NewWebSiteData.name}}"/>
43+
<argument name="storeGroupName" value="{{NewStoreData.name}}"/>
44+
<argument name="storeGroupCode" value="{{NewStoreData.code}}"/>
45+
</actionGroup>
46+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createSecondStoreView">
47+
<argument name="StoreGroup" value="NewStoreData"/>
48+
<argument name="customStore" value="storeViewData"/>
49+
</actionGroup>
50+
<!--Set catalog price scope to Global-->
51+
<comment userInput="Set catalog price scope to Global" stepKey="commentSetPriceScope"/>
52+
<magentoCLI command="config:set catalog/price/scope 0" stepKey="setPriceScopeGlobal"/>
53+
<magentoCLI command="indexer:reindex catalog_product_price" stepKey="reindex"/>
54+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
55+
</before>
56+
<after>
57+
<!--Set catalog price scope to Global-->
58+
<comment userInput="Set catalog price scope to Global" stepKey="commentSetPriceScope"/>
59+
<magentoCLI command="config:set catalog/price/scope 0" stepKey="setPriceScopeGlobal"/>
60+
<!-- Delete created data and log out -->
61+
<comment userInput="Delete created data and log out" stepKey="deleteDataAndLogOut"/>
62+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
63+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
64+
<deleteData createDataKey="createProductFPTAttribute" stepKey="deleteProductFPTAttribute"/>
65+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteCustomWebsite">
66+
<argument name="websiteName" value="{{NewWebSiteData.name}}"/>
67+
</actionGroup>
68+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
69+
</after>
70+
<!-- Go to product edit page and assign it to created website -->
71+
<comment userInput="Go to product edit page and assign it to created website" stepKey="assignProductToCreatedWebsite"/>
72+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="navigateToProductPage"/>
73+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
74+
<actionGroup ref="SelectProductInWebsitesActionGroup" stepKey="selectWebsiteInProduct">
75+
<argument name="website" value="{{NewWebSiteData.name}}"/>
76+
</actionGroup>
77+
<actionGroup ref="saveProductForm" stepKey="saveProductFirstTime"/>
78+
<!-- Add Fixed Product Tax attribute -->
79+
<comment userInput="Add Fixed Product Tax attribute" stepKey="addFixedProdTaxAttr"/>
80+
<actionGroup ref="AdminProductAddFPTValueActionGroup" stepKey="addFixedProductTaxAttr">
81+
<argument name="FPTAttributeCode" value="$$createProductFPTAttribute.attribute_code$$"/>
82+
<argument name="stateForFPT" value="California"/>
83+
<argument name="valueForFPT" value="10"/>
84+
</actionGroup>
85+
<actionGroup ref="saveProductForm" stepKey="saveProductSecondTime"/>
86+
<!-- Check if created tax attribute is saved -->
87+
<comment userInput="Check if created tax attribute is saved" stepKey="checkThatTaxAttributeIsSaved"/>
88+
<seeElement selector="{{AdminProductAddFPTValueSection.setTaxValueForFPT($$createProductFPTAttribute.attribute_code$$)}}" stepKey="checkIfTaxAttributeSaved"/>
89+
<!--See available websites only 'All Websites'-->
90+
<comment userInput="See available websites only 'All Websites'" stepKey="commentCheckWebsitesDropDown"/>
91+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'All Websites')}}" stepKey="seeAllWebsites"/>
92+
<dontSeeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, NewWebSiteData.name)}}" stepKey="dontSeeSecondWebsite"/>
93+
<dontSeeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'Main Website')}}" stepKey="dontSeeMainWebsite"/>
94+
<!--Set catalog price scope to Website-->
95+
<comment userInput="Set catalog price scope to Website" stepKey="commentSetPriceScope"/>
96+
<magentoCLI command="config:set catalog/price/scope 1" stepKey="setPriceScopeWebsite"/>
97+
<magentoCLI command="indexer:reindex catalog_product_price" stepKey="reindex"/>
98+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
99+
<!--See available websites only 'All Websites'-->
100+
<comment userInput="See available websites 'All Websites', 'Main Website' and Second website" stepKey="commentCheckWebsitesInProductPage"/>
101+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="goToProductPageSecondTime"/>
102+
<waitForPageLoad stepKey="waitForProductPageLoadSecondTime"/>
103+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'All Websites')}}" stepKey="checkAllWebsitesInDropDown"/>
104+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'Main Website')}}" stepKey="checkMainWebsiteInDropDown"/>
105+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, NewWebSiteData.name)}}" stepKey="checkSecondWebsitesInDropDown"/>
106+
<actionGroup ref="unassignWebsiteFromProductActionGroup" stepKey="unassignWebsiteInProduct">
107+
<argument name="website" value="{{_defaultWebsite.name}}"/>
108+
</actionGroup>
109+
<actionGroup ref="saveProductForm" stepKey="saveProductThirdTime"/>
110+
<waitForPageLoad stepKey="waitForSavedProductLoad"/>
111+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'All Websites')}}" stepKey="checkAllWebsitesInDropDownSecondTime"/>
112+
<dontSeeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, 'Main Website')}}" stepKey="checkNoMainWebsiteInDropDown"/>
113+
<seeElement selector="{{AdminProductAddFPTValueSection.setWebSiteForFPTOption($$createProductFPTAttribute.attribute_code$$, NewWebSiteData.name)}}" stepKey="checkSecondWebsitesInDropDownSecondTime"/>
114+
<!-- Check if created tax attribute is saved -->
115+
<comment userInput="Check if created tax attribute is saved" stepKey="checkTaxAttributeIsSaved"/>
116+
<seeInField selector="{{AdminProductAddFPTValueSection.setTaxValueForFPT($$createProductFPTAttribute.attribute_code$$)}}" userInput="10" stepKey="checkTaxAttributeSaved"/>
117+
</test>
118+
</tests>

app/code/Magento/Weee/Ui/DataProvider/Product/Form/Modifier/Manager/Website.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Weee\Ui\DataProvider\Product\Form\Modifier\Manager;
79

810
use Magento\Catalog\Api\Data\ProductInterface;
@@ -12,6 +14,8 @@
1214
use Magento\Directory\Model\Currency;
1315
use Magento\Store\Api\Data\WebsiteInterface;
1416
use Magento\Store\Model\StoreManagerInterface;
17+
use Magento\Catalog\Helper\Data;
18+
use Magento\Framework\App\ObjectManager;
1519

1620
/**
1721
* Class Website
@@ -23,19 +27,27 @@ class Website
2327
*/
2428
private $websites;
2529

30+
/**
31+
* @var Data
32+
*/
33+
private $catalogHelper;
34+
2635
/**
2736
* @param LocatorInterface $locator
2837
* @param StoreManagerInterface $storeManager
2938
* @param DirectoryHelper $directoryHelper
39+
* @param Data|null $catalogHelper
3040
*/
3141
public function __construct(
3242
LocatorInterface $locator,
3343
StoreManagerInterface $storeManager,
34-
DirectoryHelper $directoryHelper
44+
DirectoryHelper $directoryHelper,
45+
Data $catalogHelper = null
3546
) {
3647
$this->locator = $locator;
3748
$this->storeManager = $storeManager;
3849
$this->directoryHelper = $directoryHelper;
50+
$this->catalogHelper = $catalogHelper ?: ObjectManager::getInstance()->get(Data::class);
3951
}
4052

4153
/**
@@ -60,6 +72,7 @@ public function getWebsites(ProductInterface $product, EavAttribute $eavAttribut
6072

6173
if ($this->storeManager->hasSingleStore()
6274
|| ($eavAttribute->getEntityAttribute() && $eavAttribute->getEntityAttribute()->isScopeGlobal()
75+
|| $this->catalogHelper->isPriceGlobal()
6376
)
6477
) {
6578
return $this->websites = $websites;

0 commit comments

Comments
 (0)