From c0f9508818a29d4f49c426ef9d8b4f6dca173682 Mon Sep 17 00:00:00 2001 From: Teun Lassche Date: Wed, 9 Nov 2016 11:36:52 +0100 Subject: [PATCH 1/3] Fix issue #6999: Configurable attribute cache was never hit --- .../ConfigurableProduct/Model/Product/Type/Configurable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 0b8a4aee9fece..3c888aca7896b 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -443,15 +443,15 @@ public function getConfigurableAttributes($product) */ protected function hasCacheData($configurableAttributes) { - $configurableAttributes = $configurableAttributes ?: unserialize($configurableAttributes); - if (is_array($configurableAttributes) && count($configurableAttributes)) { + $configurableAttributes = $configurableAttributes ? unserialize($configurableAttributes) : $configurableAttributes; + if ((is_array($configurableAttributes) || $configurableAttributes instanceof \Traversable) && count($configurableAttributes)) { foreach ($configurableAttributes as $attribute) { /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $attribute */ if ($attribute->getData('options')) { return $configurableAttributes; } } - } + } return false; } From 9e263a816d8ce73603a0b93cd3d75c8dc4b37a12 Mon Sep 17 00:00:00 2001 From: Teun Lassche Date: Thu, 17 Aug 2017 16:09:40 +0200 Subject: [PATCH 2/3] Fix issue #10565: Creation of new product does not work with custom attribute set --- .../Magento/Ui/view/base/web/js/form/element/multiselect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js index bfa15728f2088..b80a4404a2fe4 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js @@ -52,7 +52,7 @@ define([ * @param {Array} data - current component value */ setPrepareToSendData: function (data) { - if (!data.length) { + if (_.isUndefined(data) || !data.length) { data = ''; } From 02c018d825a33045a44efdb4868c548ac42c7917 Mon Sep 17 00:00:00 2001 From: Teun Lassche Date: Fri, 18 Aug 2017 13:10:31 +0200 Subject: [PATCH 3/3] Add tests for multiselect with value 'undefined' --- .../Magento/Ui/base/js/form/element/multiselect.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js index 30ab33f4a1cf0..165cc1aff3ac5 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js @@ -52,6 +52,12 @@ define([ expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ''); }); + it('Check method call with undefined as parameter.', function () { + + expect(obj.setPrepareToSendData(undefined)).toBeUndefined(); + expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ''); + }); + it('Check method call with array with data as parameter.', function () { expect(obj.setPrepareToSendData(['1', '2', '3'])).toBeUndefined(); expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ['1', '2', '3']);