Skip to content

Commit c53d9a5

Browse files
[EngCom] Public Pull Requests - 2.2-develop
- merged latest code from mainline branch
2 parents a37b931 + 98ee213 commit c53d9a5

File tree

12 files changed

+282
-2
lines changed

12 files changed

+282
-2
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\CatalogUrlRewrite\Model;
10+
11+
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
12+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
13+
14+
/**
15+
* Class for creating product url through web-api.
16+
*/
17+
class WebapiProductUrlPathGenerator extends ProductUrlPathGenerator
18+
{
19+
/**
20+
* @var CollectionFactory
21+
*/
22+
private $collectionFactory;
23+
24+
/**
25+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
26+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
27+
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
28+
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
29+
* @param CollectionFactory $collectionFactory
30+
*/
31+
public function __construct(
32+
\Magento\Store\Model\StoreManagerInterface $storeManager,
33+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
34+
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
35+
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
36+
CollectionFactory $collectionFactory
37+
) {
38+
parent::__construct($storeManager, $scopeConfig, $categoryUrlPathGenerator, $productRepository);
39+
$this->collectionFactory = $collectionFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
protected function prepareProductUrlKey(\Magento\Catalog\Model\Product $product)
46+
{
47+
$urlKey = $product->getUrlKey();
48+
if ($urlKey === '' || $urlKey === null) {
49+
$urlKey = $this->prepareUrlKey($product->formatUrlKey($product->getName()));
50+
}
51+
52+
return $product->formatUrlKey($urlKey);
53+
}
54+
55+
/**
56+
* Crete url key if it does not exist yet.
57+
*
58+
* @param string $urlKey
59+
* @return string
60+
*/
61+
private function prepareUrlKey(string $urlKey) : string
62+
{
63+
/** @var ProductCollection $collection */
64+
$collection = $this->collectionFactory->create();
65+
$collection->addFieldToFilter('url_key', ['like' => $urlKey]);
66+
if ($collection->getSize() !== 0) {
67+
$urlKey = $urlKey . '-1';
68+
$urlKey = $this->prepareUrlKey($urlKey);
69+
}
70+
71+
return $urlKey;
72+
}
73+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<preference for="Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator" type="Magento\CatalogUrlRewrite\Model\WebapiProductUrlPathGenerator"/>
10+
</config>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<preference for="Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator" type="Magento\CatalogUrlRewrite\Model\WebapiProductUrlPathGenerator"/>
10+
</config>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<!-- Checkout select Check/Money Order payment -->
1212
<actionGroup name="CheckoutSelectCheckMoneyOrderPaymentActionGroup">
1313
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
14-
<waitForElementVisible selector="{{CheckoutPaymentSection.billingAddress}}" time="30" stepKey="waitForBillingAddressDetailsAppears"/>
1514
<conditionalClick selector="{{CheckoutPaymentSection.checkMoneyOrderPayment}}" dependentSelector="{{CheckoutPaymentSection.checkMoneyOrderPayment}}" visible="true" stepKey="clickCheckMoneyOrderPayment"/>
1615
</actionGroup>
1716

app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<entity name="RegionTX" type="region">
1616
<data key="region">Texas</data>
1717
<data key="region_code">TX</data>
18-
<data key="region_id">1</data>
18+
<data key="region_id">57</data>
1919
</entity>
2020
<entity name="RegionCA" type="region">
2121
<data key="region">California</data>

app/code/Magento/Paypal/Model/Api/PayflowNvp.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp
136136
'CVV2MATCH' => 'cvv2_check_result',
137137

138138
'USERSELECTEDFUNDINGSOURCE' => 'funding_source',
139+
140+
'NOSHIPPING' => 'suppress_shipping',
141+
'REQBILLINGADDRESS' => 'require_billing_address',
139142
];
140143

141144
/**
@@ -248,6 +251,8 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp
248251
'PAYFLOWCOLOR',
249252
'LOCALECODE',
250253
'USERSELECTEDFUNDINGSOURCE',
254+
'NOSHIPPING',
255+
'REQBILLINGADDRESS',
251256
];
252257

253258
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Weee\Plugin\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
7+
8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
10+
use Magento\Framework\App\RequestInterface;
11+
12+
/**
13+
* Handles product tax attributes data initialization.
14+
*/
15+
class ProcessTaxAttribute
16+
{
17+
/**
18+
* @var RequestInterface
19+
*/
20+
private $request;
21+
22+
/**
23+
* @param RequestInterface $request
24+
*/
25+
public function __construct(RequestInterface $request)
26+
{
27+
$this->request = $request;
28+
}
29+
30+
/**
31+
* @param Helper $subject
32+
* @param Product $result
33+
* @param Product $product
34+
* @param array $productData
35+
* @return Product
36+
*
37+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
38+
*/
39+
public function afterInitializeFromData(
40+
Helper $subject,
41+
Product $result,
42+
Product $product,
43+
array $productData
44+
): Product {
45+
$attributes = $result->getAttributes();
46+
if (!empty($attributes)) {
47+
foreach ($attributes as $attribute) {
48+
if ($attribute->getFrontendInput() == 'weee' && !isset($productData[$attribute->getAttributeCode()])) {
49+
$result->setData($attribute->getAttributeCode(), []);
50+
}
51+
}
52+
}
53+
54+
return $result;
55+
}
56+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductAddFPTValueSection">
1212
<element name="addFPT" type="button" selector="[data-index='{{FPTAttributeCode}}'] [data-action='add_new_row']" parameterized="true"/>
13+
<element name="removeRowByIndex" type="button" selector="[data-index='{{FPTAttributeCode}}'] [data-action='remove_row']:nth-of-type({{rowIndex}})" parameterized="true"/>
1314
<element name="selectCountryForFPT" type="select" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[country]')])[last()]" parameterized="true"/>
1415
<element name="selectStateForFPT" type="select" selector="(//select[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[state]')])[last()]" parameterized="true"/>
1516
<element name="setTaxValueForFPT" type="text" selector="(//input[contains(@name, 'product[{{FPTAttributeCode}}]') and contains(@name, '[value]')])[last()]" parameterized="true"/>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
<test name="AdminRemoveProductWeeeAttributeOptionTest">
11+
<annotations>
12+
<features value="Weee attribute options can be removed in product page"/>
13+
<title value="Weee attribute options can be removed in product page"/>
14+
<description value="Weee attribute options can be removed in product page"/>
15+
<severity value="CRITICAL"/>
16+
<testCaseId value="MAGETWO-94817"/>
17+
<group value="weee"/>
18+
</annotations>
19+
<before>
20+
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
21+
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
22+
<requiredEntity createDataKey="createProductFPTAttribute"/>
23+
</createData>
24+
<createData entity="SimpleOne" stepKey="createSimpleProduct"/>
25+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
26+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProductInitial">
27+
<argument name="product" value="$$createSimpleProduct$$"/>
28+
</actionGroup>
29+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProductInitial">
30+
<argument name="product" value="$$createSimpleProduct$$"/>
31+
</actionGroup>
32+
<actionGroup ref="AdminProductAddFPTValueActionGroup" stepKey="addWeeeAttributeValue">
33+
<argument name="FPTAttributeCode" value="$$createProductFPTAttribute.attribute_code$$"/>
34+
<argument name="stateForFPT" value="California"/>
35+
<argument name="valueForFPT" value="10"/>
36+
</actionGroup>
37+
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProductInitial"/>
38+
</before>
39+
<after>
40+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductListing"/>
41+
<waitForPageLoad stepKey="waitForProductListingPageLoad"/>
42+
<actionGroup ref="AdminResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
43+
<actionGroup ref="logout" stepKey="logout"/>
44+
<deleteData createDataKey="createProductFPTAttribute" stepKey="deleteProductFPTAttribute"/>
45+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
46+
</after>
47+
<!-- Test Steps -->
48+
<!-- Step 1: Open created product edit page -->
49+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
50+
<argument name="product" value="$$createSimpleProduct$$"/>
51+
</actionGroup>
52+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
53+
<argument name="product" value="$$createSimpleProduct$$"/>
54+
</actionGroup>
55+
<!-- Step 2: Remove weee attribute options -->
56+
<click selector="{{AdminProductAddFPTValueSection.removeRowByIndex('$$createProductFPTAttribute.attribute_code$$','1')}}" stepKey="removeAttributeOption"/>
57+
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProduct"/>
58+
<!-- Assert weee attribute options are empty -->
59+
<dontSeeElement selector="{{AdminProductAddFPTValueSection.removeRowByIndex('$$createProductFPTAttribute.attribute_code$$','1')}}" stepKey="dontSeeOptions"/>
60+
</test>
61+
</tests>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
180180
'component' => 'Magento_Weee/js/fpt-group',
181181
'visible' => true,
182182
'label' => __('Country/State'),
183+
'showLabel' => false,
183184
],
184185
],
185186
],
@@ -197,6 +198,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
197198
'validation' => [
198199
'required-entry' => true,
199200
],
201+
'showLabel' => false,
200202
],
201203
],
202204
],
@@ -216,6 +218,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
216218
],
217219
'caption' => '*',
218220
'visible' => true,
221+
'showLabel' => false,
219222
],
220223
],
221224
],
@@ -233,6 +236,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
233236
'validation' => [
234237
'validate-fpt-group' => true
235238
],
239+
'showLabel' => false,
236240
],
237241
],
238242
],
@@ -252,6 +256,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
252256
'validation' => [
253257
'required-entry' => true
254258
],
259+
'showLabel' => false,
255260
],
256261
],
257262
],
@@ -267,6 +272,7 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
267272
'label' => __('Website'),
268273
'visible' => $this->websiteManager->isMultiWebsites(),
269274
'options' => $this->websiteManager->getWebsites($product, $eavAttribute),
275+
'showLabel' => false,
270276
],
271277
],
272278
],

0 commit comments

Comments
 (0)