diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 1dfbf18ae773d..12a4d4d138f53 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -155,8 +155,9 @@ public function getQuote() if ($this->getStoreId()) { if (!$this->getQuoteId()) { $this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId()); + $this->_quote->setIsActive(false); $this->_quote->setStoreId($this->getStoreId()); - + $this->quoteRepository->save($this->_quote); $this->setQuoteId($this->_quote->getId()); $this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index b39e6610b9dbe..00bfe1a4f9419 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -343,6 +343,7 @@ public function testGetQuoteWithoutQuoteId() '', false ); + $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock); $cartInterfaceMock->expects($this->once()) ->method('setCustomerGroupId') @@ -357,7 +358,6 @@ public function testGetQuoteWithoutQuoteId() $quoteMock->expects($this->once()) ->method('setIsSuperMode') ->with(true); - $this->assertEquals($quoteMock, $this->quote->getQuote()); } diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml index cae13fc26cc69..d7fae5232f456 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml @@ -51,6 +51,7 @@ require([ showHour: false, showMinute: false, serverTimezoneSeconds: getStoreTimestamp(); ?>, + serverTimezoneOffset: getTimezoneOffsetSeconds(); ?>, yearRange: 'getYearRange() ?>' } }); diff --git a/app/code/Magento/Braintree/Controller/Paypal/Review.php b/app/code/Magento/Braintree/Controller/Paypal/Review.php index b2b95f7897856..1b6c3a3ab5a91 100644 --- a/app/code/Magento/Braintree/Controller/Paypal/Review.php +++ b/app/code/Magento/Braintree/Controller/Paypal/Review.php @@ -10,6 +10,7 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Braintree\Gateway\Config\PayPal\Config; use Magento\Braintree\Model\Paypal\Helper\QuoteUpdater; +use Magento\Framework\Exception\LocalizedException; /** * Class Review @@ -21,6 +22,11 @@ class Review extends AbstractAction */ private $quoteUpdater; + /** + * @var string + */ + private static $paymentMethodNonce = 'payment_method_nonce'; + /** * Constructor * @@ -52,13 +58,16 @@ public function execute() try { $this->validateQuote($quote); - $this->validateRequestData($requestData); - $this->quoteUpdater->execute( - $requestData['nonce'], - $requestData['details'], - $quote - ); + if ($this->validateRequestData($requestData)) { + $this->quoteUpdater->execute( + $requestData['nonce'], + $requestData['details'], + $quote + ); + } elseif (!$quote->getPayment()->getAdditionalInformation(self::$paymentMethodNonce)) { + throw new LocalizedException(__('We can\'t initialize checkout.')); + } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); @@ -82,13 +91,10 @@ public function execute() /** * @param array $requestData - * @return void - * @throws \InvalidArgumentException + * @return boolean */ private function validateRequestData(array $requestData) { - if (empty($requestData['nonce']) || empty($requestData['details'])) { - throw new \InvalidArgumentException('Data of request cannot be empty.'); - } + return !empty($requestData['nonce']) && !empty($requestData['details']); } } diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index 4f1c053d31fba..a5cdaf3e35b70 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -170,7 +170,7 @@ public function testExecuteException() $quoteMock->expects(self::once()) ->method('getItemsCount') - ->willReturn(1); + ->willReturn(0); $this->requestMock->expects(self::once()) ->method('getPostValue') @@ -188,7 +188,54 @@ public function testExecuteException() ->method('addExceptionMessage') ->with( self::isInstanceOf('\InvalidArgumentException'), - 'Data of request cannot be empty.' + 'We can\'t initialize checkout.' + ); + + $this->resultFactoryMock->expects(self::once()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($resultRedirectMock); + + $resultRedirectMock->expects(self::once()) + ->method('setPath') + ->with('checkout/cart') + ->willReturnSelf(); + + self::assertEquals($this->review->execute(), $resultRedirectMock); + } + + public function testExecuteExceptionPaymentWithoutNonce() + { + $result = '{}'; + $quoteMock = $this->getQuoteMock(); + $resultRedirectMock = $this->getResultRedirectMock(); + + $quoteMock->expects(self::once()) + ->method('getItemsCount') + ->willReturn(1); + + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) + ->disableOriginalConstructor() + ->getMock(); + + $quoteMock->expects(self::once()) + ->method('getPayment') + ->willReturn($paymentMock); + + $this->requestMock->expects(self::once()) + ->method('getPostValue') + ->with('result', '{}') + ->willReturn($result); + + $this->checkoutSessionMock->expects(self::once()) + ->method('getQuote') + ->willReturn($quoteMock); + + $this->messageManagerMock->expects(self::once()) + ->method('addExceptionMessage') + ->with( + self::isInstanceOf(\Magento\Framework\Exception\LocalizedException::class), + 'We can\'t initialize checkout.' ); $this->resultFactoryMock->expects(self::once()) diff --git a/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml b/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml index 99494ff5d889d..35cb4617ec9ed 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml @@ -27,7 +27,7 @@ $config = [ data-locale="getLocale(); ?>" data-amount="getAmount(); ?>" id="" - class="action-braintree-paypal-logo"> + class="action-braintree-paypal-logo" disabled> diff --git a/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js b/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js index d6c0384e54c10..c2a5326aa31f6 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js @@ -4,6 +4,7 @@ */ define( [ + 'rjsResolver', 'uiRegistry', 'uiComponent', 'underscore', @@ -13,6 +14,7 @@ define( 'domReady!' ], function ( + resolver, registry, Component, _, @@ -47,8 +49,10 @@ define( * @param {Object} integration */ onReady: function (integration) { - registry.set(this.integrationName, integration); - $('#' + this.id).removeAttr('disabled'); + resolver(function () { + registry.set(this.integrationName, integration); + $('#' + this.id).removeAttr('disabled'); + }, this); }, /** diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js index e1f72e3c8cb11..7d34055512cf1 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js @@ -15,6 +15,7 @@ define([ return { apiClient: null, config: {}, + checkout: null, /** * Get Braintree api client diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js index f087da176df9b..6990c1e2e5a0b 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js @@ -184,10 +184,11 @@ define( /** * Device data initialization * - * @param {Object} braintreeInstance + * @param {Object} checkout */ - onReady: function (braintreeInstance) { - this.additionalData['device_data'] = braintreeInstance.deviceData; + onReady: function (checkout) { + braintree.checkout = checkout; + this.additionalData['device_data'] = checkout.deviceData; } }; diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js index 4155f2c25f8b0..df3d5a116699c 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js @@ -15,8 +15,6 @@ define([ ], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators) { 'use strict'; - var checkout; - return Component.extend({ defaults: { template: 'Magento_Braintree/payment/paypal', @@ -33,10 +31,10 @@ define([ /** * Triggers when widget is loaded - * @param {Object} integration + * @param {Object} checkout */ - onReady: function (integration) { - checkout = integration; + onReady: function (checkout) { + Braintree.checkout = checkout; this.enableButton(); }, @@ -144,12 +142,36 @@ define([ this.paymentMethodNonce = paymentMethodNonce; }, + /** + * Update quote billing address + * @param {Object}customer + * @param {Object}address + */ + setBillingAddress: function (customer, address) { + var billingAddress = { + street: [address.streetAddress], + city: address.locality, + regionCode: address.region, + postcode: address.postalCode, + countryId: address.countryCodeAlpha2, + firstname: customer.firstName, + lastname: customer.lastName, + telephone: customer.phone + }; + + quote.billingAddress(billingAddress); + }, + /** * Prepare data to place order * @param {Object} data */ beforePlaceOrder: function (data) { this.setPaymentMethodNonce(data.nonce); + + if (quote.billingAddress() === null && typeof data.details.billingAddress !== 'undefined') { + this.setBillingAddress(data.details, data.details.billingAddress); + } this.placeOrder(); }, @@ -157,12 +179,12 @@ define([ * Re-init PayPal Auth Flow */ reInitPayPal: function () { - if (!checkout) { - return; + if (Braintree.checkout) { + Braintree.checkout.teardown(function () { + Braintree.checkout = null; + }); } - checkout.teardown(function () { - checkout = null; - }); + this.disableButton(); this.clientConfig.paypal.amount = this.grandTotalAmount; @@ -175,7 +197,7 @@ define([ */ payWithPayPal: function () { if (additionalValidators.validate()) { - checkout.paypal.initAuthFlow(); + Braintree.checkout.paypal.initAuthFlow(); } }, @@ -200,8 +222,7 @@ define([ * @returns {Object} */ getPayPalConfig: function () { - var address = quote.shippingAddress(), - totals = quote.totals(), + var totals = quote.totals(), config = {}; config.paypal = { @@ -212,16 +233,6 @@ define([ currency: totals['base_currency_code'], locale: this.getLocale(), enableShippingAddress: true, - shippingAddressOverride: { - recipientName: address.firstname + ' ' + address.lastname, - streetAddress: address.street[0], - locality: address.city, - countryCodeAlpha2: address.countryId, - postalCode: address.postcode, - region: address.regionCode, - phone: address.telephone, - editable: this.isAllowOverrideShippingAddress() - }, /** * Triggers on any Braintree error @@ -238,6 +249,8 @@ define([ } }; + config.paypal.shippingAddressOverride = this.getShippingAddress(); + if (this.getMerchantName()) { config.paypal.displayName = this.getMerchantName(); } @@ -245,6 +258,30 @@ define([ return config; }, + /** + * Get shipping address + * @returns {Object} + */ + getShippingAddress: function () { + var address = quote.shippingAddress(); + + if (address.postcode === null) { + + return {}; + } + + return { + recipientName: address.firstname + ' ' + address.lastname, + streetAddress: address.street[0], + locality: address.city, + countryCodeAlpha2: address.countryId, + postalCode: address.postcode, + region: address.regionCode, + phone: address.telephone, + editable: this.isAllowOverrideShippingAddress() + }; + }, + /** * Get merchant name * @returns {String} @@ -279,6 +316,8 @@ define([ * Disable submit button */ disableButton: function () { + // stop any previous shown loaders + fullScreenLoader.stopLoader(); fullScreenLoader.startLoader(); $('[data-button="place"]').attr('disabled', 'disabled'); }, diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml index 9a7db79414836..3f15701216005 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml @@ -40,7 +40,6 @@ -isRedirectToCartEnabled()) : ?> - - \ No newline at end of file diff --git a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php index ca520a6a0acaf..a57a1f91dcf66 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php +++ b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php @@ -58,7 +58,7 @@ public function beforeSavePaymentInformationAndPlaceOrder( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } @@ -77,17 +77,21 @@ public function beforeSavePaymentInformation( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } /** - * @param int[] $agreements + * @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod * @throws \Magento\Framework\Exception\CouldNotSaveException * @return void */ - protected function validateAgreements($agreements) + protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod) { + $agreements = $paymentMethod->getExtensionAttributes() === null + ? [] + : $paymentMethod->getExtensionAttributes()->getAgreementIds(); + if (!$this->agreementsValidator->isValid($agreements)) { throw new \Magento\Framework\Exception\CouldNotSaveException( __('Please agree to all the terms and conditions before placing the order.') diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php index 268a746d91998..a2440cf7641a2 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php @@ -85,7 +85,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -107,7 +107,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(false); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -125,7 +125,7 @@ public function testBeforeSavePaymentInformation() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js index 0e0bd2c2234b5..d0876cc49ce0f 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js @@ -9,6 +9,9 @@ var config = { mixins: { 'Magento_Checkout/js/action/place-order': { 'Magento_CheckoutAgreements/js/model/place-order-mixin': true + }, + 'Magento_Checkout/js/action/set-payment-information': { + 'Magento_CheckoutAgreements/js/model/set-payment-information-mixin': true } } } diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js index 793978cb8e474..3d030a62eb425 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js @@ -14,6 +14,8 @@ define( var checkoutConfig = window.checkoutConfig, agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {}; + var agreementsInputPath = '.payment-method._active div.checkout-agreements input'; + return { /** * Validate checkout agreements @@ -25,6 +27,10 @@ define( return true; } + if ($(agreementsInputPath).length == 0) { + return true; + } + return $('#co-payment-form').validate({ errorClass: 'mage-error', errorElement: 'div', @@ -36,7 +42,7 @@ define( } errorPlacement.after(error); } - }).element('.payment-method._active div.checkout-agreements input'); + }).element(agreementsInputPath); } } } diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js new file mode 100644 index 0000000000000..cd2c486f0923c --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery' +], function ($) { + 'use strict'; + + var agreementsConfig = window.checkoutConfig.checkoutAgreements; + + /** Override default place order action and add agreement_ids to request */ + return function (paymentData) { + var agreementForm, + agreementData, + agreementIds; + + if (!agreementsConfig.isEnabled) { + return; + } + + agreementForm = $('.payment-method._active div[data-role=checkout-agreements] input'); + agreementData = agreementForm.serializeArray(); + agreementIds = []; + + agreementData.forEach(function (item) { + agreementIds.push(item.value); + }); + + if (paymentData['extension_attributes'] === undefined) { + paymentData['extension_attributes'] = {}; + } + + paymentData['extension_attributes']['agreement_ids'] = agreementIds; + }; +}); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js index b7008e8556223..ac459e573f9f2 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js @@ -6,35 +6,16 @@ /*global alert*/ define([ 'jquery', - 'mage/utils/wrapper' -], function ($, wrapper) { + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { 'use strict'; - var agreementsConfig = window.checkoutConfig.checkoutAgreements; - return function (placeOrderAction) { /** Override default place order action and add agreement_ids to request */ return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, messageContainer) { - var agreementForm, - agreementData, - agreementIds; - - if (!agreementsConfig.isEnabled) { - return originalAction(paymentData, messageContainer); - } - - agreementForm = $('.payment-method._active form[data-role=checkout-agreements]'); - agreementData = agreementForm.serializeArray(); - agreementIds = []; - - agreementData.forEach(function (item) { - agreementIds.push(item.value); - }); - - paymentData.extension_attributes = { - agreement_ids: agreementIds - }; + agreementsAssigner(paymentData); return originalAction(paymentData, messageContainer); }); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js new file mode 100644 index 0000000000000..159568a8b1bec --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery', + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { + 'use strict'; + + return function (placeOrderAction) { + + /** Override place-order-mixin for set-payment-information action as they differs only by method signature */ + return wrapper.wrap(placeOrderAction, function (originalAction, messageContainer, paymentData) { + agreementsAssigner(paymentData); + + return originalAction(messageContainer, paymentData); + }); + }; +}); diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php index e7a3e8ae19ba4..67ec8ec2b654d 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php @@ -5,6 +5,8 @@ */ namespace Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action; +use Magento\Store\Api\StoreResolverInterface; + class UrlBuilder { /** @@ -33,8 +35,12 @@ public function getUrl($routePath, $scope, $store) $this->frontendUrlBuilder->setScope($scope); $href = $this->frontendUrlBuilder->getUrl( $routePath, - ['_current' => false, '_query' => '___store=' . $store] + [ + '_current' => false, + '_query' => [StoreResolverInterface::PARAM_NAME => $store] + ] ); + return $href; } } diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 4cd95cb5b4ba9..2d9e162d85f1c 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -1260,7 +1260,6 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) $width = $packageParams->getWidth(); $length = $packageParams->getLength(); $weightUnits = $packageParams->getWeightUnits() == \Zend_Measure_Weight::POUND ? 'LB' : 'KG'; - $dimensionsUnits = $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM'; $unitPrice = 0; $itemsQty = 0; $itemsDesc = []; @@ -1403,12 +1402,12 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) // set dimensions if ($length || $width || $height) { - $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = []; - $dimenssions = &$requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions']; - $dimenssions['Length'] = $length; - $dimenssions['Width'] = $width; - $dimenssions['Height'] = $height; - $dimenssions['Units'] = $dimensionsUnits; + $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = [ + 'Length' => $length, + 'Width' => $width, + 'Height' => $height, + 'Units' => $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM' + ]; } return $this->_getAuthDetails() + $requestClient; diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php index 501f38834bc4d..eb45a53b98995 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php @@ -128,12 +128,13 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c $items = []; while (false !== ($csvLine = $file->readCsv())) { try { + $rowNumber++; if (empty($csvLine)) { continue; } $rowData = $this->rowParser->parse( $csvLine, - ++$rowNumber, + $rowNumber, $websiteId, $conditionShortName, $conditionFullName, @@ -151,7 +152,7 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c ) ); } - $this->uniqueHash[$hash] = $csvLine; + $this->uniqueHash[$hash] = $rowNumber; $items[] = $rowData; if (count($items) === $bunchSize) { diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php index 0bb192e3deacb..a3a2a5d1fbb8f 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php @@ -188,7 +188,7 @@ public function testGetDataWithDuplicatedLine() } $this->assertEquals($expectedResult, $result); $this->assertTrue($this->import->hasErrors()); - $this->assertEquals(['Duplicate Row #%1 (duplicates row #%2)'], $this->import->getErrors()); + $this->assertEquals(['Duplicate Row #3 (duplicates row #2)'], $this->import->getErrors()); } /** diff --git a/app/code/Magento/Payment/Block/Form/Cc.php b/app/code/Magento/Payment/Block/Form/Cc.php index 1871da613b254..9fcd03b446470 100644 --- a/app/code/Magento/Payment/Block/Form/Cc.php +++ b/app/code/Magento/Payment/Block/Form/Cc.php @@ -108,6 +108,7 @@ public function hasVerification() /** * Whether switch/solo card type available * + * @deprecated unused * @return bool */ public function hasSsCardType() @@ -123,6 +124,7 @@ public function hasSsCardType() /** * Solo/switch card start year * + * @deprecated unused * @return array */ public function getSsStartYears() diff --git a/app/code/Magento/Payment/Model/CcConfig.php b/app/code/Magento/Payment/Model/CcConfig.php index e80edc45da0ef..bb57756fb7e1d 100644 --- a/app/code/Magento/Payment/Model/CcConfig.php +++ b/app/code/Magento/Payment/Model/CcConfig.php @@ -62,6 +62,7 @@ public function __construct( * Solo/switch card start years * * @return array + * @deprecated unused */ public function getSsStartYears() { @@ -119,6 +120,7 @@ public function hasVerification() * Whether switch/solo card type available * * @return bool + * @deprecated unused */ public function hasSsCardType() { diff --git a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php index 768c1368f3af4..a29bff3576a16 100644 --- a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php +++ b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php @@ -51,8 +51,6 @@ public function getConfig() 'months' => [$methodCode => $this->getCcMonths()], 'years' => [$methodCode => $this->getCcYears()], 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], - 'hasSsCardType' => [$methodCode => $this->hasSsCardType($methodCode)], - 'ssStartYears' => [$methodCode => $this->getSsStartYears()], 'cvvImageUrl' => [$methodCode => $this->getCvvImageUrl()] ] ] @@ -66,6 +64,7 @@ public function getConfig() * Solo/switch card start years * * @return array + * @deprecated unused */ protected function getSsStartYears() { @@ -144,6 +143,7 @@ protected function hasVerification($methodCode) * * @param string $methodCode * @return bool + * @deprecated unused */ protected function hasSsCardType($methodCode) { diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php index aa4b8c0587a69..46663d30d8a0d 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php @@ -44,12 +44,6 @@ protected function setUp() ); } - public function testGetSsStartYears() - { - $this->assertCount(6, $this->model->getSsStartYears()); - $this->assertEquals(date("Y"), $this->model->getSsStartYears()[date("Y")]); - } - public function testGetCcAvailableTypes() { $data = [1, 2, 3]; @@ -85,11 +79,6 @@ public function testHasVerification() $this->assertEquals(true, $this->model->hasVerification()); } - public function testHasSsCardType() - { - $this->assertEquals(false, $this->model->hasSsCardType()); - } - public function testGetCvvImageUrl() { $params = ['_secure' => true]; diff --git a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml index f07aceb5ddb5f..bddf821c3b376 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml @@ -80,72 +80,4 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); - - hasSsCardType()): ?> -