From d4923aa0e43e49a114ba3c293cc16715e8b2e1d1 Mon Sep 17 00:00:00 2001 From: Vladyslav Shcherbyna Date: Thu, 25 Aug 2016 16:37:03 +0300 Subject: [PATCH 01/15] MAGETWO-54808: [Backport] Unable to mass-edit a product attribute for a configurable product --- .../Controller/Adminhtml/Product/Action/Attribute/Save.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index abe72e14dd310..f878b89e14fc4 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -132,7 +132,7 @@ public function execute() $attributesData[$attributeCode] = $value; } elseif ($attribute->getFrontendInput() == 'multiselect') { // Check if 'Change' checkbox has been checked by admin for this attribute - $isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox'); + $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode); if (!$isChanged) { unset($attributesData[$attributeCode]); continue; From 8da91cb704c25cd87fbfd92adb6085eb5982cbf7 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Fri, 26 Aug 2016 14:19:27 +0300 Subject: [PATCH 02/15] MAGETWO-57039: [Backport] Update gallery entry via API doesn't work - for 2.1 --- .../Magento/Catalog/Model/Product/Gallery/GalleryManagement.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php index 9670b7e035e52..54ca19480536d 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php @@ -96,6 +96,7 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry) foreach ($existingMediaGalleryEntries as $key => $existingEntry) { if ($existingEntry->getId() == $entry->getId()) { $found = true; + $entry->setId(null); $existingMediaGalleryEntries[$key] = $entry; break; } From 6a6c3b73a251fe4b03b009056636063df0282cf5 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Fri, 26 Aug 2016 14:52:51 +0300 Subject: [PATCH 03/15] MAGETWO-57039: [Backport] Update gallery entry via API doesn't work - for 2.1 --- .../Test/Unit/Model/Product/Gallery/GalleryManagementTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php index 0e4d357164481..313fe15e7d45f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php @@ -194,6 +194,7 @@ public function testUpdate() $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); $entryMock->expects($this->once())->method('getId')->willReturn($entryId); + $entryMock->expects($this->once())->method('setId')->with(null); $this->productMock->expects($this->once())->method('setMediaGalleryEntries') ->willReturn([$entryMock]); From f06cbf6512ca2ba087a87a42cf97ad1c8a65af2d Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Tue, 30 Aug 2016 16:11:23 +0300 Subject: [PATCH 04/15] MAGETWO-57136: [GitHub] Wrong initialization sequence in mage.priceBox widget (price-box.js) #6117 --- .../Catalog/view/base/web/js/price-box.js | 39 +++++++++++-------- .../Test/Js/_files/blacklist/magento.txt | 1 - 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/view/base/web/js/price-box.js b/app/code/Magento/Catalog/view/base/web/js/price-box.js index b095d24cf4810..e615e8fdd09ab 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-box.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-box.js @@ -2,6 +2,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ + define([ 'jquery', 'Magento_Catalog/js/price-utils', @@ -29,6 +30,7 @@ define([ */ _init: function initPriceBox() { var box = this.element; + box.trigger('updatePrice'); this.cache.displayPrices = utils.deepClone(this.options.prices); }, @@ -70,7 +72,8 @@ define([ updatePrice: function updatePrice(newPrices) { var prices = this.cache.displayPrices, additionalPrice = {}, - pricesCode = []; + pricesCode = [], + priceValue, origin, final; this.cache.additionalPriceObject = this.cache.additionalPriceObject || {}; @@ -89,19 +92,19 @@ define([ pricesCode = _.keys(additional); } _.each(pricesCode, function (priceCode) { - var priceValue = additional[priceCode] || {}; + priceValue = additional[priceCode] || {}; priceValue.amount = +priceValue.amount || 0; priceValue.adjustments = priceValue.adjustments || {}; additionalPrice[priceCode] = additionalPrice[priceCode] || { - 'amount': 0, - 'adjustments': {} - }; - additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) - + priceValue.amount; + 'amount': 0, + 'adjustments': {} + }; + additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) + + priceValue.amount; _.each(priceValue.adjustments, function (adValue, adCode) { - additionalPrice[priceCode].adjustments[adCode] = 0 - + (additionalPrice[priceCode].adjustments[adCode] || 0) + adValue; + additionalPrice[priceCode].adjustments[adCode] = 0 + + (additionalPrice[priceCode].adjustments[adCode] || 0) + adValue; }); }); }); @@ -110,8 +113,8 @@ define([ this.cache.displayPrices = utils.deepClone(this.options.prices); } else { _.each(additionalPrice, function (option, priceCode) { - var origin = this.options.prices[priceCode] || {}, - final = prices[priceCode] || {}; + origin = this.options.prices[priceCode] || {}; + final = prices[priceCode] || {}; option.amount = option.amount || 0; origin.amount = origin.amount || 0; origin.adjustments = origin.adjustments || {}; @@ -127,6 +130,7 @@ define([ this.element.trigger('reloadPrice'); }, + /*eslint-disable no-extra-parens*/ /** * Render price unit block. */ @@ -135,16 +139,19 @@ define([ priceTemplate = mageTemplate(this.options.priceTemplate); _.each(this.cache.displayPrices, function (price, priceCode) { - price.final = _.reduce(price.adjustments, function(memo, amount) { + price.final = _.reduce(price.adjustments, function (memo, amount) { return memo + amount; }, price.amount); price.formatted = utils.formatPrice(price.final, priceFormat); - $('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price})); + $('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({ + data: price + })); }, this); }, + /*eslint-enable no-extra-parens*/ /** * Overwrites initial (default) prices object. * @param {Object} prices @@ -177,6 +184,7 @@ define([ var box = this.element, priceHolders = $('[data-price-type]', box), prices = this.options.prices; + this.options.productId = box.data('productId'); if (_.isEmpty(prices)) { @@ -199,10 +207,7 @@ define([ _setDefaultsFromPriceConfig: function _setDefaultsFromPriceConfig() { var config = this.options.priceConfig; - if (config) { - if (+config.productId !== +this.options.productId) { - return; - } + if (config && config.prices) { this.options.prices = config.prices; } } diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt index c1f91eec45b72..25096baf46912 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -43,7 +43,6 @@ app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js -app/code/Magento/Catalog/view/base/web/js/price-box.js app/code/Magento/Catalog/view/base/web/js/price-option-date.js app/code/Magento/Catalog/view/base/web/js/price-option-file.js app/code/Magento/Catalog/view/base/web/js/price-options.js From 12f3b8f6e41455f2f663bcbfff765aae51919ade Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Tue, 30 Aug 2016 16:41:50 +0300 Subject: [PATCH 05/15] MAGETWO-57136: [GitHub] Wrong initialization sequence in mage.priceBox widget (price-box.js) #6117 --- app/code/Magento/Catalog/view/base/web/js/price-box.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/view/base/web/js/price-box.js b/app/code/Magento/Catalog/view/base/web/js/price-box.js index e615e8fdd09ab..8d1bec72a2313 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-box.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-box.js @@ -73,7 +73,7 @@ define([ var prices = this.cache.displayPrices, additionalPrice = {}, pricesCode = [], - priceValue, origin, final; + priceValue, origin, finalPrice; this.cache.additionalPriceObject = this.cache.additionalPriceObject || {}; @@ -114,15 +114,15 @@ define([ } else { _.each(additionalPrice, function (option, priceCode) { origin = this.options.prices[priceCode] || {}; - final = prices[priceCode] || {}; + finalPrice = prices[priceCode] || {}; option.amount = option.amount || 0; origin.amount = origin.amount || 0; origin.adjustments = origin.adjustments || {}; - final.adjustments = final.adjustments || {}; + finalPrice.adjustments = finalPrice.adjustments || {}; - final.amount = 0 + origin.amount + option.amount; + finalPrice.amount = 0 + origin.amount + option.amount; _.each(option.adjustments, function (pa, paCode) { - final.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa; + finalPrice.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa; }); }, this); } From 9d62762aac3e9efddaf9f129d72daff632d7645b Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Wed, 31 Aug 2016 10:55:24 +0300 Subject: [PATCH 06/15] MAGETWO-57062: [Backport] - Issues with minicart in multiwebsite - for 2.1 --- .../Magento/Checkout/Block/Cart/Sidebar.php | 3 ++- .../Magento/Checkout/CustomerData/Cart.php | 1 + .../Test/Unit/Block/Cart/SidebarTest.php | 7 +++++-- .../Test/Unit/CustomerData/CartTest.php | 20 +++++++++++++++---- .../view/frontend/web/js/view/minicart.js | 3 +++ 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php index 74c28382c4459..1dcdc00c1cfe2 100644 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php +++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php @@ -69,7 +69,8 @@ public function getConfig() 'removeItemUrl' => $this->getRemoveItemUrl(), 'imageTemplate' => $this->getImageHtmlTemplate(), 'baseUrl' => $this->getBaseUrl(), - 'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount() + 'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount(), + 'websiteId' => $this->_storeManager->getStore()->getWebsiteId() ]; } diff --git a/app/code/Magento/Checkout/CustomerData/Cart.php b/app/code/Magento/Checkout/CustomerData/Cart.php index c4e59036c39e8..dacae4365baa0 100644 --- a/app/code/Magento/Checkout/CustomerData/Cart.php +++ b/app/code/Magento/Checkout/CustomerData/Cart.php @@ -96,6 +96,7 @@ public function getSectionData() 'items' => $this->getRecentItems(), 'extra_actions' => $this->layout->createBlock('Magento\Catalog\Block\ShortcutButtons')->toHtml(), 'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(), + 'website_id' => $this->getQuote()->getStore()->getWebsiteId() ]; } diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php index b3eabf44bd117..8fbd38ce7c7b7 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php @@ -124,6 +124,7 @@ public function testGetTotalsHtml() public function testGetConfig() { $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $websiteId = 100; $shoppingCartUrl = 'http://url.com/cart'; $checkoutUrl = 'http://url.com/checkout'; @@ -139,7 +140,8 @@ public function testGetConfig() 'removeItemUrl' => $removeItemUrl, 'imageTemplate' => $imageTemplate, 'baseUrl' => $baseUrl, - 'minicartMaxItemsVisible' => 3 + 'minicartMaxItemsVisible' => 3, + 'websiteId' => $websiteId ]; $valueMap = [ @@ -156,8 +158,9 @@ public function testGetConfig() $this->urlBuilderMock->expects($this->exactly(4)) ->method('getUrl') ->willReturnMap($valueMap); - $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $this->storeManagerMock->expects($this->exactly(2))->method('getStore')->willReturn($storeMock); $storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); + $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); $this->imageHelper->expects($this->once())->method('getFrame')->willReturn(false); $this->scopeConfigMock->expects($this->once()) diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php index aa14559983be5..2fe2c8fbade6d 100644 --- a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php @@ -90,6 +90,7 @@ public function testGetSectionData() $subtotalValue = 200; $productId = 10; $storeId = 20; + $websiteId = 100; $productRewrite = [$productId => ['rewrite' => 'product']]; $itemData = ['item' => 'data']; $shortcutButtonsHtml = 'Buttons'; @@ -100,7 +101,7 @@ public function testGetSectionData() $quoteMock = $this->getMock( '\Magento\Quote\Model\Quote', - ['getTotals', 'getHasError', 'getAllVisibleItems'], + ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'], [], '', false @@ -109,6 +110,10 @@ public function testGetSectionData() $quoteMock->expects($this->once())->method('getTotals')->willReturn($totals); $quoteMock->expects($this->once())->method('getHasError')->willReturn(false); + $storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false); + $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); + $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $this->checkoutCartMock->expects($this->once())->method('getSummaryQty')->willReturn($summaryQty); $this->checkoutHelperMock->expects($this->once()) ->method('formatPrice') @@ -166,7 +171,8 @@ public function testGetSectionData() ['item' => 'data'] ], 'extra_actions' => 'Buttons', - 'isGuestCheckoutAllowed' => 1 + 'isGuestCheckoutAllowed' => 1, + 'website_id' => $websiteId ]; $this->assertEquals($expectedResult, $this->model->getSectionData()); } @@ -180,6 +186,7 @@ public function testGetSectionDataWithCompositeProduct() $subtotalValue = 200; $productId = 10; $storeId = 20; + $websiteId = 100; $productRewrite = [$productId => ['rewrite' => 'product']]; $itemData = ['item' => 'data']; @@ -190,7 +197,7 @@ public function testGetSectionDataWithCompositeProduct() $quoteMock = $this->getMock( '\Magento\Quote\Model\Quote', - ['getTotals', 'getHasError', 'getAllVisibleItems'], + ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'], [], '', false @@ -216,6 +223,10 @@ public function testGetSectionDataWithCompositeProduct() $quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn([$quoteItemMock]); + $storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false); + $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); + $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $productMock = $this->getMock( '\Magento\Catalog\Model\Product', ['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'], @@ -271,7 +282,8 @@ public function testGetSectionDataWithCompositeProduct() ['item' => 'data'] ], 'extra_actions' => 'Buttons', - 'isGuestCheckoutAllowed' => 1 + 'isGuestCheckoutAllowed' => 1, + 'website_id' => $websiteId ]; $this->assertEquals($expectedResult, $this->model->getSectionData()); } diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js index 3cc5b90233738..41cfeed9f79fc 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js @@ -97,6 +97,9 @@ define([ addToCartCalls++; self.isLoading(true); }); + if (cartData().website_id !== window.checkout.websiteId) { + customerData.reload(['cart'], false); + } return this._super(); }, From d735423cafb73bfe0ff9f96120eb232d11e879d9 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 31 Aug 2016 17:44:44 +0300 Subject: [PATCH 07/15] MAGETWO-55184: [GitHub #5526]Selected category is not added to Cart Price Rule condition due to JS error --- .../Adminhtml/Promo/Quote/Edit/Tab/Actions.php | 2 +- .../Controller/Adminhtml/Promo/Quote/Edit.php | 18 +++++++++--------- .../Adminhtml/Promo/Quote/NewActionHtml.php | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php index ec23aa0f54070..e127e3e1c6379 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php @@ -176,7 +176,7 @@ protected function addTabToForm($model, $fieldsetId = 'actions_fieldset', $formN $actionsFieldSetId = $model->getActionsFieldSetId($formName); $newChildUrl = $this->getUrl( - 'sales_rule/promo_quote/newActionHtml/form/rule_actions_fieldset_' . $actionsFieldSetId, + 'sales_rule/promo_quote/newActionHtml/form/' . $actionsFieldSetId, ['form_namespace' => $formName] ); diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php index 1cdc62b20bb68..cc46af24f8253 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php @@ -55,6 +55,15 @@ public function execute() $this->_redirect('sales_rule/*'); return; } + $model->getConditions()->setFormName('sales_rule_form'); + $model->getConditions()->setJsFormObject( + $model->getConditionsFieldSetId($model->getConditions()->getFormName()) + ); + $model->getActions()->setFormName('sales_rule_form'); + $model->getActions()->setJsFormObject( + $model->getActionsFieldSetId($model->getActions()->getFormName()) + ); + $resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true); } @@ -65,15 +74,6 @@ public function execute() $model->addData($data); } - $model->getConditions()->setFormName('sales_rule_form'); - $model->getConditions()->setJsFormObject( - $model->getConditionsFieldSetId($model->getConditions()->getFormName()) - ); - $model->getActions()->setFormName('sales_rule_form'); - $model->getActions()->setJsFormObject( - $model->getActionsFieldSetId($model->getActions()->getFormName()) - ); - $this->_initAction(); $this->_addBreadcrumb($id ? __('Edit Rule') : __('New Rule'), $id ? __('Edit Rule') : __('New Rule')); diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php index 2397a4d2d4106..c93f9a96d2dd5 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php @@ -16,7 +16,7 @@ class NewActionHtml extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote public function execute() { $id = $this->getRequest()->getParam('id'); - $formName = $this->getRequest()->getParam('form_namespace'); + $formName = $this->getRequest()->getParam('form'); $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type'))); $type = $typeArr[0]; From ac5876fae516e0654a4a8857d9882138f7310047 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 1 Sep 2016 12:04:52 +0300 Subject: [PATCH 08/15] MAGETWO-57168: CLONE - [GitHub]JavaScript Error on Checkout Page after Changing Country in Estimate Shipping and Tax Block --- app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js index 555c10ee04b70..ac2b439b9a0f6 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js @@ -49,13 +49,13 @@ define([ return _.mapObject({ "min_text_length": [ function (value, params) { - return value.length == 0 || value.length >= +params; + return _.isUndefined(value) || value.length === 0 || value.length >= +params; }, $.mage.__('Please enter more or equal than {0} symbols.') ], "max_text_length": [ function (value, params) { - return value.length <= +params; + return !_.isUndefined(value) && value.length <= +params; }, $.mage.__('Please enter less or equal than {0} symbols.') ], From 9a43bad5ff1e060ec142f5391bcb3db9a4eb5cc5 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 2 Sep 2016 11:01:56 +0300 Subject: [PATCH 09/15] MAGETWO-57843: [Backport] - [Github # 6294] Coupon code override cart rules with no coupon code - for 2.1 --- .../Model/ResourceModel/Rule/Collection.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php b/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php index 3d814f635f15a..5ae6c37cf9dbb 100644 --- a/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php +++ b/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\SalesRule\Model\ResourceModel\Rule; use Magento\Quote\Model\Quote\Address; @@ -153,11 +151,12 @@ public function setValidationFilter( ['code'] ); + $noCouponWhereCondition = $connection->quoteInto( + 'main_table.coupon_type = ? ', + \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON + ); + $orWhereConditions = [ - $connection->quoteInto( - 'main_table.coupon_type = ? ', - \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON - ), $connection->quoteInto( '(main_table.coupon_type = ? AND rule_coupons.type = 0)', \Magento\SalesRule\Model\Rule::COUPON_TYPE_AUTO @@ -186,7 +185,9 @@ public function setValidationFilter( $orWhereCondition = implode(' OR ', $orWhereConditions); $andWhereCondition = implode(' AND ', $andWhereConditions); - $select->where('(' . $orWhereCondition . ') AND ' . $andWhereCondition); + $select->where( + $noCouponWhereCondition . ' OR ((' . $orWhereCondition . ') AND ' . $andWhereCondition . ')' + ); } else { $this->addFieldToFilter( 'main_table.coupon_type', @@ -214,7 +215,7 @@ public function setValidationFilter( public function addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now = null) { if (!$this->getFlag('website_group_date_filter')) { - if (is_null($now)) { + if ($now === null) { $now = $this->_date->date()->format('Y-m-d'); } @@ -277,7 +278,11 @@ public function addAttributeInConditionFilter($attributeCode) $field = $this->_getMappedField('actions_serialized'); $aCond = $this->_getConditionSql($field, ['like' => $match]); - $this->getSelect()->where(sprintf('(%s OR %s)', $cCond, $aCond), null, \Magento\Framework\DB\Select::TYPE_CONDITION); + $this->getSelect()->where( + sprintf('(%s OR %s)', $cCond, $aCond), + null, + \Magento\Framework\DB\Select::TYPE_CONDITION + ); return $this; } From deac1fe56935e3d98857650e953ae6f0ff87a6c5 Mon Sep 17 00:00:00 2001 From: aakimov Date: Fri, 22 Jul 2016 16:32:28 +0300 Subject: [PATCH 10/15] MAGETWO-57512: Order Status is Set to Processing when Vitual Product is Purchased by Payment that Automatically Captures Funds - Added fix from support team with required tests; --- .../Model/ResourceModel/Order/Handler/State.php | 3 --- .../ResourceModel/Order/Handler/StateTest.php | 15 +++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php index a3fa5812ccd9f..d8c456ca159c7 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php @@ -23,9 +23,6 @@ class State */ public function check(Order $order) { - if (!$order->getId()) { - return $order; - } if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) { if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) { if ($order->getState() !== Order::STATE_COMPLETE) { diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php index cce9ba279d008..dad51eda86e19 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php @@ -74,9 +74,12 @@ protected function setUp() public function testCheckOrderEmpty() { $this->orderMock->expects($this->once()) - ->method('getId') - ->will($this->returnValue(null)); - $this->assertEquals($this->orderMock, $this->state->check($this->orderMock)); + ->method('getBaseGrandTotal') + ->willReturn(100); + $this->orderMock->expects($this->never()) + ->method('setState'); + + $this->state->check($this->orderMock); } /** @@ -84,7 +87,7 @@ public function testCheckOrderEmpty() */ public function testCheckSetStateComplete() { - $this->orderMock->expects($this->once()) + $this->orderMock->expects($this->any()) ->method('getId') ->will($this->returnValue(1)); $this->orderMock->expects($this->once()) @@ -120,7 +123,7 @@ public function testCheckSetStateComplete() */ public function testCheckSetStateClosed() { - $this->orderMock->expects($this->once()) + $this->orderMock->expects($this->any()) ->method('getId') ->will($this->returnValue(1)); $this->orderMock->expects($this->once()) @@ -162,7 +165,7 @@ public function testCheckSetStateClosed() */ public function testCheckSetStateProcessing() { - $this->orderMock->expects($this->once()) + $this->orderMock->expects($this->any()) ->method('getId') ->will($this->returnValue(1)); $this->orderMock->expects($this->once()) From 67467f7081cff65d8a3c07150d141a31e7524731 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 2 Sep 2016 15:31:27 +0300 Subject: [PATCH 11/15] MAGETWO-57843: [Backport] - [Github # 6294] Coupon code override cart rules with no coupon code - for 2.1 --- .../SalesRule/Model/ResourceModel/Rule/CollectionTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/Model/ResourceModel/Rule/CollectionTest.php b/dev/tests/integration/testsuite/Magento/SalesRule/Model/ResourceModel/Rule/CollectionTest.php index 19ec7b420c872..bc8b0aba4d816 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/Model/ResourceModel/Rule/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/Model/ResourceModel/Rule/CollectionTest.php @@ -42,15 +42,15 @@ public function testSetValidationFilter($couponCode, $expectedItems) public function setValidationFilterDataProvider() { return [ - 'Check type COUPON' => ['coupon_code', ['#1', '#5']], + 'Check type COUPON' => ['coupon_code', ['#1', '#2', '#5']], 'Check type NO_COUPON' => ['', ['#2', '#5']], - 'Check type COUPON_AUTO' => ['coupon_code_auto', ['#4', '#5']], - 'Check result with auto generated coupon' => ['autogenerated_3_1', ['#3', '#5']], + 'Check type COUPON_AUTO' => ['coupon_code_auto', ['#2', '#4', '#5']], + 'Check result with auto generated coupon' => ['autogenerated_3_1', ['#2', '#3', '#5']], 'Check result with non actual previously generated coupon' => [ 'autogenerated_2_1', ['#2', '#5'], ], - 'Check result with wrong code' => ['wrong_code', ['#5']] + 'Check result with wrong code' => ['wrong_code', ['#2', '#5']] ]; } From 091682cab942c2789d0bd4369f415a8711f6e337 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Thu, 1 Sep 2016 14:49:21 +0300 Subject: [PATCH 12/15] MAGETWO-57039: [Backport] Update gallery entry via API doesn't work - for 2.1 --- .../Catalog/Model/Product/Gallery/GalleryManagement.php | 4 +++- .../Test/Unit/Model/Product/Gallery/GalleryManagementTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php index 54ca19480536d..950e2253a95dc 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php @@ -96,7 +96,9 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry) foreach ($existingMediaGalleryEntries as $key => $existingEntry) { if ($existingEntry->getId() == $entry->getId()) { $found = true; - $entry->setId(null); + if ($entry->getFile()) { + $entry->setId(null); + } $existingMediaGalleryEntries[$key] = $entry; break; } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php index 313fe15e7d45f..dc9855f538bdf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php @@ -194,6 +194,7 @@ public function testUpdate() $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); $entryMock->expects($this->once())->method('getId')->willReturn($entryId); + $entryMock->expects($this->once())->method('getFile')->willReturn("base64"); $entryMock->expects($this->once())->method('setId')->with(null); $this->productMock->expects($this->once())->method('setMediaGalleryEntries') From 997336680deca8306b59700454c928982436e03d Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 8 Sep 2016 11:23:58 +0300 Subject: [PATCH 13/15] MAGETWO-57062: [Backport] - Issues with minicart in multiwebsite - for 2.1 --- app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php index 2fe2c8fbade6d..a700c8f6703e8 100644 --- a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php @@ -112,7 +112,7 @@ public function testGetSectionData() $storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false); $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); - $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); $this->checkoutCartMock->expects($this->once())->method('getSummaryQty')->willReturn($summaryQty); $this->checkoutHelperMock->expects($this->once()) From 15534a170b062e50442e184ec64822a5dbb4e3f7 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 8 Sep 2016 12:42:45 +0300 Subject: [PATCH 14/15] MAGETWO-58183: Fix L3 static tests fail --- app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php | 2 ++ app/code/Magento/Sales/Model/Order/Invoice.php | 1 + .../TestFramework/Workaround/Cleanup/StaticProperties.php | 1 - .../Magento/ConfigurableImportExport/Model/ConfigurableTest.php | 1 - 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php index e76f644a8275f..a55e4d15738c4 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php @@ -112,10 +112,12 @@ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInte * Base discount tax compensation amount. */ const BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT = 'base_discount_tax_compensation_amount'; + /** * Invoice */ const INVOICE = 'invoice'; + /** * Gets the additional data for the invoice item. * diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index a977de41c5585..af3aa1985f4d6 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -792,6 +792,7 @@ public function getComments() } //@codeCoverageIgnoreStart + /** * Returns increment id * diff --git a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php index ae49af296f7c2..bd4391ffb1509 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php @@ -123,7 +123,6 @@ protected static function _isClassInCleanableFolders($classFile) return false; // File is not in an "include" directory } - /** * Restore static variables (after running controller test case) * @TODO: refactor all code where objects are stored to static variables to use object manager instead diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php index c00b73e70b8e2..8e97a30790ffe 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php @@ -42,7 +42,6 @@ protected function assertEqualsSpecificAttributes($expectedProduct, $actualProdu $actualAssociatedProductSkus[] = $actualAssociatedProducts[$i]->getSku(); } - $this->assertEquals($expectedAssociatedProductSkus, $actualAssociatedProductSkus); $expectedProductExtensionAttributes = $expectedProduct->getExtensionAttributes(); From 28b3a2e1f51df283d9532b3d89e7a60af35214f9 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 8 Sep 2016 13:21:23 +0300 Subject: [PATCH 15/15] MAGETWO-58183: Fix L3 static tests fail --- .../Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php index cc46af24f8253..6b1c4db190951 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php @@ -64,7 +64,6 @@ public function execute() $model->getActionsFieldSetId($model->getActions()->getFormName()) ); - $resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true); }