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

Commit b4269c2

Browse files
author
Alexander Akimov
authored
Merge pull request #3509 from magento-tsg/2.2-develop-pr60
[TSG] Backporting for 2.2 (pr60) (2.2.8)
2 parents 8c6000f + edd3a2f commit b4269c2

File tree

31 files changed

+574
-170
lines changed

31 files changed

+574
-170
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<!--Login as any user-->
12+
<actionGroup name="AdminLoginAsAnyUser">
13+
<arguments>
14+
<argument name="login" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_USERNAME}}"/>
15+
<argument name="password" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
16+
</arguments>
17+
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
18+
<fillField userInput="{{login}}" selector="{{AdminLoginFormSection.username}}" stepKey="fillUsername"/>
19+
<fillField userInput="{{password}}" selector="{{AdminLoginFormSection.password}}" stepKey="fillPassword"/>
20+
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/>
21+
<closeAdminNotification stepKey="closeAdminNotification"/>
22+
</actionGroup>
23+
</actionGroups>

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,23 @@
169169
<waitForPageLoad stepKey="waitForPageLoad"/>
170170
<dontSeeElement selector="{{AdminProductImagesSection.imageFile(image.filename)}}" stepKey="seeImage"/>
171171
</actionGroup>
172+
<actionGroup name="CreatedProductConnectToWebsite">
173+
<arguments>
174+
<argument name="website"/>
175+
<argument name="product"/>
176+
</arguments>
177+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductGridPage"/>
178+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
179+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
180+
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillProductSkuFilter"/>
181+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
182+
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad" time="30"/>
183+
<click selector="{{AdminProductGridSection.firstRow}}" stepKey="openProduct"/>
184+
<waitForPageLoad stepKey="waitForProductPage"/>
185+
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="scrollToWebsites"/>
186+
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openWebsitesList"/>
187+
<click selector="{{ProductInWebsitesSection.website(website.name)}}" stepKey="selectWebsite"/>
188+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/>
189+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
190+
</actionGroup>
172191
</actionGroups>

app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ public function __construct(
195195
}
196196

197197
/**
198+
* Initialize template for error message.
199+
*
198200
* @param array $templateCollection
199201
* @return $this
200202
*/
@@ -377,6 +379,8 @@ public function retrieveAttributeFromCache($attributeCode)
377379
}
378380

379381
/**
382+
* Adding attribute option.
383+
*
380384
* In case we've dynamically added new attribute option during import we need to add it to our cache
381385
* in order to keep it up to date.
382386
*
@@ -508,8 +512,10 @@ public function isSuitable()
508512
}
509513

510514
/**
511-
* Prepare attributes values for save: exclude non-existent, static or with empty values attributes;
512-
* set default values if needed
515+
* Adding default attribute to product before save.
516+
*
517+
* Prepare attributes values for save: exclude non-existent, static or with empty values attributes,
518+
* set default values if needed.
513519
*
514520
* @param array $rowData
515521
* @param bool $withDefaultValue
@@ -537,9 +543,9 @@ public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDe
537543
} else {
538544
$resultAttrs[$attrCode] = $rowData[$attrCode];
539545
}
540-
} elseif (array_key_exists($attrCode, $rowData)) {
546+
} elseif (array_key_exists($attrCode, $rowData) && empty($rowData['_store'])) {
541547
$resultAttrs[$attrCode] = $rowData[$attrCode];
542-
} elseif ($withDefaultValue && null !== $attrParams['default_value']) {
548+
} elseif ($withDefaultValue && null !== $attrParams['default_value'] && empty($rowData['_store'])) {
543549
$resultAttrs[$attrCode] = $attrParams['default_value'];
544550
}
545551
}
@@ -605,7 +611,8 @@ protected function getProductEntityLinkField()
605611
}
606612

607613
/**
608-
* Clean cached values
614+
* Clean cached values.
615+
*
609616
* @since 100.2.0
610617
*/
611618
public function __destruct()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminCreateCustomerWithWebsiteAndStoreViewActionGroup">
11+
<arguments>
12+
<argument name="customer"/>
13+
<argument name="address"/>
14+
<argument name="websiteName" type="string"/>
15+
<argument name="storeViewName" type="string"/>
16+
</arguments>
17+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersPage"/>
18+
<click selector="{{AdminCustomerGridMainActionsSection.addNewCustomer}}" stepKey="addNewCustomer"/>
19+
<selectOption selector="{{AdminCustomerAccountInformationSection.associateToWebsite}}" userInput="{{websiteName}}" stepKey="selectWebSite"/>
20+
<fillField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="{{customer.firstname}}" stepKey="fillFirstName"/>
21+
<fillField selector="{{AdminCustomerAccountInformationSection.lastName}}" userInput="{{customer.lastname}}" stepKey="fillLastName"/>
22+
<fillField selector="{{AdminCustomerAccountInformationSection.email}}" userInput="{{customer.email}}" stepKey="fillEmail"/>
23+
<selectOption selector="{{AdminCustomerAccountInformationSection.storeView}}" userInput="{{storeViewName}}" stepKey="selectStoreView"/>
24+
<scrollToTopOfPage stepKey="scrollToTopOfThePage"/>
25+
<click selector="{{AdminCustomerAccountInformationSection.addressesButton}}" stepKey="goToAddresses"/>
26+
<waitForPageLoad stepKey="waitForAddresses"/>
27+
<click selector="{{AdminCustomerEditAddressesSection.addNewAddress}}" stepKey="clickOnAddNewAddress"/>
28+
<waitForPageLoad stepKey="waitForAddressFields"/>
29+
<click selector="{{AdminCustomerEditAddressesSection.defaultBillingAddress}}" stepKey="tickBillingAddress"/>
30+
<click selector="{{AdminCustomerEditAddressesSection.defaultShippingAddress}}" stepKey="tickShippingAddress"/>
31+
<fillField selector="{{AdminCustomerEditAddressesSection.firstName}}" userInput="{{address.firstname}}" stepKey="fillFirstNameForAddress"/>
32+
<fillField selector="{{AdminCustomerEditAddressesSection.lastName}}" userInput="{{address.lastname}}" stepKey="fillLastNameForAddress"/>
33+
<fillField selector="{{AdminCustomerEditAddressesSection.streetAddress}}" userInput="{{address.street[0]}}" stepKey="fillStreetAddress"/>
34+
<fillField selector="{{AdminCustomerEditAddressesSection.city}}" userInput="{{address.city}}" stepKey="fillCity"/>
35+
<selectOption selector="{{AdminCustomerEditAddressesSection.country}}" userInput="{{address.country}}" stepKey="selectCountry"/>
36+
<selectOption selector="{{AdminCustomerEditAddressesSection.state}}" userInput="{{address.state}}" stepKey="selectState"/>
37+
<fillField selector="{{AdminCustomerEditAddressesSection.zip}}" userInput="{{address.postcode}}" stepKey="fillZip"/>
38+
<fillField selector="{{AdminCustomerEditAddressesSection.phoneNumber}}" userInput="{{address.telephone}}" stepKey="fillPhoneNumber"/>
39+
<click selector="{{AdminMainActionsSection.save}}" stepKey="save"/>
40+
<see userInput="You saved the customer." stepKey="seeSuccessMessage"/>
41+
</actionGroup>
42+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<data key="default_billing">Yes</data>
8989
<data key="default_shipping">Yes</data>
9090
<requiredEntity type="region">RegionNY</requiredEntity>
91+
<data key="country">United States</data>
9192
</entity>
9293
<entity name="UK_Default_Address" type="address">
9394
<data key="firstname">Jane</data>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<section name="AdminCustomerAccountInformationSection">
1010
<element name="accountInformationTitle" type="text" selector=".admin__page-nav-title"/>
1111
<element name="accountInformationButton" type="text" selector="//a/span[text()='Account Information']"/>
12+
<element name="addressesButton" type="select" selector="//a//span[contains(text(), 'Addresses')]"/>
1213
<element name="firstName" type="input" selector="input[name='customer[firstname]']"/>
1314
<element name="lastName" type="input" selector="input[name='customer[lastname]']"/>
1415
<element name="email" type="input" selector="input[name='customer[email]']"/>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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="AdminCustomerEditAddressesSection">
12+
<element name="addNewAddress" type="button" selector="//span[text()='Add New Addresses']"/>
13+
<element name="defaultBillingAddress" type="button" selector="//label[text()='Default Billing Address']"/>
14+
<element name="defaultShippingAddress" type="button" selector="//label[text()='Default Shipping Address']"/>
15+
<element name="firstName" type="button" selector="input[name*='address'][name*=firstname]"/>
16+
<element name="lastName" type="button" selector="input[name*='address'][name*=lastname]"/>
17+
<element name="streetAddress" type="button" selector="input[name*='address'][name*=street]"/>
18+
<element name="city" type="input" selector="input[name*='address'][name*=city]"/>
19+
<element name="country" type="select" selector="select[name*='address'][name*=country_id]"/>
20+
<element name="state" type="select" selector="select[name*=address][name*=region_id]"/>
21+
<element name="zip" type="input" selector="input[name*=address][name*=postcode]"/>
22+
<element name="phoneNumber" type="input" selector="input[name*=address][name*=telephone]"/>
23+
</section>
24+
</sections>

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ public function getBehavior()
554554
$this->_parameters['behavior']
555555
) ||
556556
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_APPEND &&
557+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_ADD_UPDATE &&
557558
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_REPLACE &&
558559
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_DELETE
559560
) {

app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/credit-card-number-validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ define([
3636
return resultWrapper(null, false, false);
3737
}
3838

39-
value = value.replace(/\-|\s/g, '');
39+
value = value.replace(/|\s/g, '');
4040

4141
if (!/^\d*$/.test(value)) {
4242
return resultWrapper(null, false, false);

app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
2424
'use strict';
2525

26+
$('.payment-method-content input[type="number"]').on('keyup', function () {
27+
if ($(this).val() < 0) {
28+
$(this).val($(this).val().replace(/^-/, ''));
29+
}
30+
});
31+
2632
$.each({
2733
'validate-card-type': [
2834
function (number, item, allowedTypes) {
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Magento\Persistent\Observer;
10+
11+
use Magento\Framework\Event\ObserverInterface;
12+
13+
/**
14+
* Observer for a work with persistent data.
15+
*/
16+
class SetCheckoutSessionPersistentDataObserver implements ObserverInterface
17+
{
18+
/**
19+
* Persistent session.
20+
*
21+
* @var \Magento\Persistent\Helper\Session
22+
*/
23+
private $persistentSession = null;
24+
25+
/**
26+
* Customer session.
27+
*
28+
* @var \Magento\Customer\Model\Session
29+
*/
30+
private $customerSession;
31+
32+
/**
33+
* Persistent data.
34+
*
35+
* @var \Magento\Persistent\Helper\Data
36+
*/
37+
private $persistentData = null;
38+
39+
/**
40+
* Customer Repository.
41+
*
42+
* @var \Magento\Customer\Api\CustomerRepositoryInterface
43+
*/
44+
private $customerRepository = null;
45+
46+
/**
47+
* @param \Magento\Persistent\Helper\Session $persistentSession
48+
* @param \Magento\Customer\Model\Session $customerSession
49+
* @param \Magento\Persistent\Helper\Data $persistentData
50+
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
51+
*/
52+
public function __construct(
53+
\Magento\Persistent\Helper\Session $persistentSession,
54+
\Magento\Customer\Model\Session $customerSession,
55+
\Magento\Persistent\Helper\Data $persistentData,
56+
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
57+
) {
58+
$this->persistentSession = $persistentSession;
59+
$this->customerSession = $customerSession;
60+
$this->persistentData = $persistentData;
61+
$this->customerRepository = $customerRepository;
62+
}
63+
64+
/**
65+
* Pass customer data from persistent session to checkout session and set quote to be loaded even if not active.
66+
*
67+
* @param \Magento\Framework\Event\Observer $observer
68+
* @return void
69+
*/
70+
public function execute(\Magento\Framework\Event\Observer $observer)
71+
{
72+
/** @var $checkoutSession \Magento\Checkout\Model\Session */
73+
$checkoutSession = $observer->getEvent()->getData('checkout_session');
74+
if ($this->persistentData->isShoppingCartPersist() && $this->persistentSession->isPersistent()) {
75+
$checkoutSession->setCustomerData(
76+
$this->customerRepository->getById($this->persistentSession->getSession()->getCustomerId())
77+
);
78+
}
79+
if (!(($this->persistentSession->isPersistent() && !$this->customerSession->isLoggedIn())
80+
&& !$this->persistentData->isShoppingCartPersist()
81+
)) {
82+
return;
83+
}
84+
if ($checkoutSession) {
85+
$checkoutSession->setLoadInactive();
86+
}
87+
}
88+
}

app/code/Magento/Persistent/Observer/SetLoadPersistentQuoteObserver.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)