Skip to content

Commit 762e0d5

Browse files
Merge branch 2.2-develop into ENGCOM-3940-magento-magento2-20509
2 parents 7df5394 + 401203a commit 762e0d5

File tree

53 files changed

+1291
-345
lines changed

Some content is hidden

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

53 files changed

+1291
-345
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ class TableBuilder
3434
*/
3535
private $tableBuilderFactory;
3636

37-
/**
38-
* Check whether builder was executed
39-
*
40-
* @var bool
41-
*/
42-
protected $_isExecuted = false;
43-
4437
/**
4538
* Constructor
4639
*
@@ -70,9 +63,6 @@ public function __construct(
7063
*/
7164
public function build($storeId, $changedIds, $valueFieldSuffix)
7265
{
73-
if ($this->_isExecuted) {
74-
return;
75-
}
7666
$entityTableName = $this->_productIndexerHelper->getTable('catalog_product_entity');
7767
$attributes = $this->_productIndexerHelper->getAttributes();
7868
$eavAttributes = $this->_productIndexerHelper->getTablesStructure($attributes);
@@ -117,7 +107,6 @@ public function build($storeId, $changedIds, $valueFieldSuffix)
117107
//Fill temporary tables with attributes grouped by it type
118108
$this->_fillTemporaryTable($tableName, $columns, $changedIds, $valueFieldSuffix, $storeId);
119109
}
120-
$this->_isExecuted = true;
121110
}
122111

123112
/**

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ protected function duplicate($product)
308308

309309
$this->resourceModel->duplicate(
310310
$this->getAttribute()->getAttributeId(),
311-
isset($mediaGalleryData['duplicate']) ? $mediaGalleryData['duplicate'] : [],
311+
$mediaGalleryData['duplicate'] ?? [],
312312
$product->getOriginalLinkId(),
313313
$product->getData($this->metadata->getLinkField())
314314
);

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Catalog\Model\ResourceModel\Product;
78

89
use Magento\Store\Model\Store;
@@ -141,7 +142,7 @@ public function loadProductGalleryByAttributeId($product, $attributeId)
141142
*/
142143
protected function createBaseLoadSelect($entityId, $storeId, $attributeId)
143144
{
144-
$select = $this->createBatchBaseSelect($storeId, $attributeId);
145+
$select = $this->createBatchBaseSelect($storeId, $attributeId);
145146

146147
$select = $select->where(
147148
'entity.' . $this->metadata->getLinkField() . ' = ?',
@@ -362,9 +363,9 @@ public function deleteGalleryValueInStore($valueId, $entityId, $storeId)
362363
$conditions = implode(
363364
' AND ',
364365
[
365-
$this->getConnection()->quoteInto('value_id = ?', (int) $valueId),
366-
$this->getConnection()->quoteInto($this->metadata->getLinkField() . ' = ?', (int) $entityId),
367-
$this->getConnection()->quoteInto('store_id = ?', (int) $storeId)
366+
$this->getConnection()->quoteInto('value_id = ?', (int)$valueId),
367+
$this->getConnection()->quoteInto($this->metadata->getLinkField() . ' = ?', (int)$entityId),
368+
$this->getConnection()->quoteInto('store_id = ?', (int)$storeId)
368369
]
369370
);
370371

@@ -392,7 +393,7 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
392393

393394
$select = $this->getConnection()->select()->from(
394395
[$this->getMainTableAlias() => $this->getMainTable()],
395-
['value_id', 'value']
396+
['value_id', 'value', 'media_type', 'disabled']
396397
)->joinInner(
397398
['entity' => $this->getTable(self::GALLERY_VALUE_TO_ENTITY_TABLE)],
398399
$this->getMainTableAlias() . '.value_id = entity.value_id',
@@ -409,16 +410,16 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
409410

410411
// Duplicate main entries of gallery
411412
foreach ($this->getConnection()->fetchAll($select) as $row) {
412-
$data = [
413-
'attribute_id' => $attributeId,
414-
'value' => isset($newFiles[$row['value_id']]) ? $newFiles[$row['value_id']] : $row['value'],
415-
];
413+
$data = $row;
414+
$data['attribute_id'] = $attributeId;
415+
$data['value'] = $newFiles[$row['value_id']] ?? $row['value'];
416+
unset($data['value_id']);
416417

417418
$valueIdMap[$row['value_id']] = $this->insertGallery($data);
418419
$this->bindValueToEntity($valueIdMap[$row['value_id']], $newProductId);
419420
}
420421

421-
if (count($valueIdMap) == 0) {
422+
if (count($valueIdMap) === 0) {
422423
return [];
423424
}
424425

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
namespace Magento\Checkout\Block\Checkout;
77

88
use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
9+
use Magento\Customer\Api\Data\CustomerInterface;
910
use Magento\Customer\Helper\Address as AddressHelper;
1011
use Magento\Customer\Model\Session;
1112
use Magento\Directory\Helper\Data as DirectoryHelper;
1213

14+
/**
15+
* Fields attribute merger.
16+
*/
1317
class AttributeMerger
1418
{
1519
/**
@@ -46,6 +50,7 @@ class AttributeMerger
4650
'alpha' => 'validate-alpha',
4751
'numeric' => 'validate-number',
4852
'alphanumeric' => 'validate-alphanum',
53+
'alphanum-with-spaces' => 'validate-alphanum-with-spaces',
4954
'url' => 'validate-url',
5055
'email' => 'email2',
5156
'length' => 'validate-length',
@@ -67,7 +72,7 @@ class AttributeMerger
6772
private $customerRepository;
6873

6974
/**
70-
* @var \Magento\Customer\Api\Data\CustomerInterface
75+
* @var CustomerInterface
7176
*/
7277
private $customer;
7378

@@ -309,6 +314,8 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi
309314
}
310315

311316
/**
317+
* Returns default attribute value.
318+
*
312319
* @param string $attributeCode
313320
* @return null|string
314321
*/
@@ -346,7 +353,9 @@ protected function getDefaultValue($attributeCode)
346353
}
347354

348355
/**
349-
* @return \Magento\Customer\Api\Data\CustomerInterface|null
356+
* Returns logged customer.
357+
*
358+
* @return CustomerInterface|null
350359
*/
351360
protected function getCustomer()
352361
{

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf
9898
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
9999
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
100100
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
101-
* @param CartExtensionFactory|null $cartExtensionFactory,
102-
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory,
101+
* @param CartExtensionFactory|null $cartExtensionFactory
102+
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory
103103
* @param ShippingFactory|null $shippingFactory
104104
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
105105
*/
@@ -150,6 +150,10 @@ public function saveAddressInformation(
150150
$address->setCustomerAddressId(null);
151151
}
152152

153+
if ($billingAddress && !$billingAddress->getCustomerAddressId()) {
154+
$billingAddress->setCustomerAddressId(null);
155+
}
156+
153157
if (!$address->getCountryId()) {
154158
throw new StateException(__('Shipping address is not set'));
155159
}
@@ -203,6 +207,8 @@ protected function validateQuote(\Magento\Quote\Model\Quote $quote)
203207
}
204208

205209
/**
210+
* Prepare shipping assignment.
211+
*
206212
* @param CartInterface $quote
207213
* @param AddressInterface $address
208214
* @param string $method

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@
3232
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
3333
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask1"/>
3434
</actionGroup>
35+
36+
<actionGroup name="GuestCheckoutFillingShippingSectionWithoutPaymentsActionGroup" extends="GuestCheckoutFillingShippingSectionActionGroup">
37+
<waitForElement selector="{{CheckoutPaymentSection.isPaymentSection}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
38+
</actionGroup>
39+
40+
<actionGroup name="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" extends="GuestCheckoutFillingShippingSectionActionGroup">
41+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country}}" after="enterPostcode" stepKey="selectCountry"/>
42+
<remove keyForRemoval="selectRegion"/>
43+
</actionGroup>
3544
</actionGroups>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups 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/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<!-- Logged in user checkout add new adress shipping section -->
1212
<actionGroup name="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup">
1313
<arguments>
@@ -21,6 +21,14 @@
2121
<fillField selector="{{CheckoutShippingSection.addTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
2222
<click selector="{{CheckoutShippingSection.addSaveButton}}" stepKey="clickSaveAdressAdd"/>
2323
<waitForPageLoad stepKey="waitPageLoad"/>
24-
<see stepKey="seeRegionSelected" selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.state}}"/>
24+
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.state}}" stepKey="seeRegionSelected"/>
25+
</actionGroup>
26+
27+
<actionGroup name="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup"
28+
extends="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup">
29+
<remove keyForRemoval="selectRegion"/>
30+
<remove keyForRemoval="seeRegionSelected"/>
31+
<selectOption selector="{{CheckoutShippingSection.addCountry}}" userInput="{{customerAddressVar.country}}" after="enterPostcode" stepKey="enterCountry"/>
32+
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.city}}" after="waitPageLoad" stepKey="seeCitySelected"/>
2533
</actionGroup>
2634
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
<element name="billingAddressSameAsShipping" type="checkbox" selector=".payment-method._active [name='billing-address-same-as-shipping']"/>
4343
<element name="orderSummaryTotal" type="text" selector="tr.grand.totals span.price" />
4444
<element name="checkPaymentMethodByName" type="radio" selector="//div[@id='checkout-payment-method-load']//div[contains(., '{{paymentName}}')]/..//input[@type='radio']" parameterized="true"/>
45+
<element name="noPaymentMethods" type="text" selector=".no-quotes-block"/>
4546
</section>
4647
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<element name="addState" type="select" selector="#shipping-new-address-form select[name='region_id']"/>
3131
<element name="addPostcode" type="input" selector="#shipping-new-address-form input[name='postcode']"/>
3232
<element name="addTelephone" type="input" selector="#shipping-new-address-form input[name='telephone']"/>
33-
<element name="addcCountry" type="select" selector="#shipping-new-address-form select[name='country_id']"/>
33+
<element name="addCountry" type="select" selector="#shipping-new-address-form select[name='country_id']"/>
3434
<element name="addSaveButton" type="button" selector=".action.primary.action-save-address"/>
3535
<element name="editActiveAddress" type="button" selector="//div[@class='shipping-address-item selected-item']//span[text()='Edit']" timeout="30"/>
3636
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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="StorefrontCustomerCheckoutTestWithRestrictedCountriesForPaymentTest"
12+
extends="StorefrontGuestCheckoutTestWithRestrictedCountriesForPaymentTest">
13+
<annotations>
14+
<stories value="Checkout via the Storefront"/>
15+
<title value="Checkout via Customer Checkout with restricted countries for payment"/>
16+
<description value="Should be able to place an order as a Customer with restricted countries for payment."/>
17+
<testCaseId value="MC-10831"/>
18+
</annotations>
19+
<before>
20+
<createData entity="Simple_US_Customer" stepKey="createSimpleUsCustomer"/>
21+
</before>
22+
<after>
23+
<actionGroup ref="CustomerLogoutStorefrontActionGroup" stepKey="customerLogoutStorefront"/>
24+
<deleteData createDataKey="createSimpleUsCustomer" stepKey="deleteCustomer"/>
25+
</after>
26+
27+
<remove keyForRemoval="guestCheckoutFillingShippingSection"/>
28+
<remove keyForRemoval="guestCheckoutFillingShippingSectionUK"/>
29+
<remove keyForRemoval="guestPlaceOrder"/>
30+
31+
<!-- Login as Customer -->
32+
<actionGroup ref="CustomerLoginOnStorefront" before="goToProductPage" stepKey="customerLogin">
33+
<argument name="customer" value="$$createSimpleUsCustomer$$" />
34+
</actionGroup>
35+
36+
<!-- Select address and go to payments page-->
37+
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{US_Address_TX.state}}" after="shippingStepIsOpened" stepKey="seeRegion" />
38+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" after="seeRegion" stepKey="waitNextButton"/>
39+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" after="waitNextButton" stepKey="selectShippingMethod"/>
40+
<click selector="{{CheckoutShippingMethodsSection.next}}" after="selectShippingMethod" stepKey="clickNextButton" />
41+
<waitForPageLoad after="clickNextButton" stepKey="waitBillingForm"/>
42+
<seeElement selector="{{CheckoutPaymentSection.isPaymentSection}}" after="waitBillingForm" stepKey="checkoutPaymentStepIsOpened"/>
43+
44+
<!-- Fill UK Address and verify that payment available and checkout successful -->
45+
<click selector="{{CheckoutShippingSection.newAdress}}" after="shippingStepIsOpened1" stepKey="fillNewAddress" />
46+
<actionGroup ref="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup" after="fillNewAddress" stepKey="customerCheckoutFillingShippingSectionUK">
47+
<argument name="customerVar" value="$$createSimpleUsCustomer$$" />
48+
<argument name="customerAddressVar" value="UK_Default_Address" />
49+
</actionGroup>
50+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" after="customerCheckoutFillingShippingSectionUK" stepKey="waitNextButton1"/>
51+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" after="waitNextButton1" stepKey="selectShippingMethod1"/>
52+
<click selector="{{CheckoutShippingMethodsSection.next}}" after="selectShippingMethod1" stepKey="clickNextButton1" />
53+
54+
<actionGroup ref="CheckoutPlaceOrderActionGroup" after="selectCheckMoneyOrderPayment" stepKey="customerPlaceorder">
55+
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage" />
56+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
57+
</actionGroup>
58+
</test>
59+
</tests>
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="StorefrontGuestCheckoutTestWithRestrictedCountriesForPaymentTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Checkout via Guest Checkout"/>
15+
<title value="Checkout via Guest Checkout with restricted countries for payment"/>
16+
<description value="Should be able to place an order as a Guest with restricted countries for payment."/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-8243"/>
19+
<group value="checkout"/>
20+
</annotations>
21+
<before>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
<magentoCLI command="config:set payment/checkmo/allowspecific" arguments="1" stepKey="setAllowSpecificCountiesValue" />
27+
<magentoCLI command="config:set payment/checkmo/specificcountry" arguments="GB" stepKey="setSpecificCountryValue" />
28+
</before>
29+
<after>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
32+
<magentoCLI command="config:set payment/checkmo/allowspecific" arguments="0" stepKey="unsetAllowSpecificCountiesValue"/>
33+
<magentoCLI command="config:set payment/checkmo/specificcountry" arguments="''" stepKey="unsetSpecificCountryValue" />
34+
</after>
35+
36+
<!-- Add product to cart -->
37+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.sku$$)}}" stepKey="goToProductPage"/>
38+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToCart">
39+
<argument name="productName" value="$$createProduct.name$$"/>
40+
</actionGroup>
41+
<!-- Go to checkout page -->
42+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart" />
43+
44+
<!-- Fill US Address and verify that no payment available -->
45+
<seeElement selector="{{CheckoutShippingSection.isShippingStep}}" stepKey="shippingStepIsOpened"/>
46+
<actionGroup ref="GuestCheckoutFillingShippingSectionWithoutPaymentsActionGroup" stepKey="guestCheckoutFillingShippingSection">
47+
<argument name="customerVar" value="Simple_US_Customer"/>
48+
<argument name="customerAddressVar" value="US_Address_TX"/>
49+
<argument name="shippingMethod" value="Flat Rate" type="string"/>
50+
</actionGroup>
51+
52+
<waitForElementVisible selector="{{CheckoutPaymentSection.noPaymentMethods}}" stepKey="waitMessage"/>
53+
<see userInput="No Payment method available." stepKey="checkMessage"/>
54+
55+
<!-- Fill UK Address and verify that payment available and checkout successful -->
56+
<click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" />
57+
<waitForElementVisible selector="{{CheckoutShippingSection.isShippingStep}}" stepKey="shippingStepIsOpened1"/>
58+
59+
<actionGroup ref="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" stepKey="guestCheckoutFillingShippingSectionUK">
60+
<argument name="customerVar" value="Simple_US_Customer" />
61+
<argument name="customerAddressVar" value="UK_Default_Address" />
62+
<argument name="shippingMethod" value="Flat Rate" type="string"/>
63+
</actionGroup>
64+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrderPayment" />
65+
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceOrder">
66+
<argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" />
67+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
68+
</actionGroup>
69+
</test>
70+
</tests>

0 commit comments

Comments
 (0)