From 51b925e2f05df08b2cf03d5c4cc013b9bc33c749 Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 14:43:31 +0530 Subject: [PATCH 1/6] Update form.phtml --- .../Catalog/view/frontend/templates/product/view/form.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index 4d7005dfe6cb..91282ac30af4 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -22,6 +22,7 @@ + getBlockHtml('formkey') ?> getChildHtml('form_top') ?> hasOptions()):?> From 357bf7c53f863ba7feb2261d95ed75129a5ca1dd Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 15:03:26 +0530 Subject: [PATCH 2/6] Set Product options by checking item id --- .../view/frontend/web/js/options-updater.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js index a355a3f3ac7c..6eeb61548f92 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js @@ -7,10 +7,12 @@ define([ var selectors = { formSelector: '#product_addtocart_form', - productIdSelector: '#product_addtocart_form [name="product"]' + productIdSelector: '#product_addtocart_form [name="product"]', + itemIdSelector:'#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), + itemId= $(selectors.itemIdSelector).val(), /** * set productOptions according to cart data from customer-data @@ -24,8 +26,10 @@ define([ if (!(data && data.items && data.items.length && productId)) { return false; } - changedProductOptions = _.find(data.items, function (item) { - return item['product_id'] === productId; + changedProductOptions = data.items.find(function (item) { + if (item['item_id'] == itemId) { + return item['product_id'] === productId; + } }); changedProductOptions = changedProductOptions && changedProductOptions.options && changedProductOptions.options.reduce(function (obj, val) { From 7bf6d95f49ff00d6ff365e58b6ef620f3054492f Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 15:05:31 +0530 Subject: [PATCH 3/6] Set Quantity by checking item id --- .../web/js/view/configure/product-customer-data.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js index d7a81decbade..cf7e73338766 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js @@ -7,10 +7,12 @@ require([ var selectors = { qtySelector: '#product_addtocart_form [name="qty"]', - productIdSelector: '#product_addtocart_form [name="product"]' + productIdSelector: '#product_addtocart_form [name="product"]', + itemIdSelector: '#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), + itemId = $(selectors.itemIdSelector).val(), productQty, productQtyInput, @@ -40,8 +42,10 @@ require([ return; } product = data.items.find(function (item) { - return item['product_id'] === productId || - item['item_id'] === productId; + if (item['item_id'] == itemId) { + return item['product_id'] === productId || + item['item_id'] === productId; + } }); if (!product) { From 6452bdcc1a2c43e045e9071adf8f115867bae500 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets Date: Thu, 19 Apr 2018 16:05:29 +0300 Subject: [PATCH 4/6] Display Wrong Data On Cart Update Page --- .../Catalog/view/frontend/templates/product/view/form.phtml | 2 +- .../frontend/web/js/view/configure/product-customer-data.js | 2 +- .../view/frontend/web/js/options-updater.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index 91282ac30af4..9c5cce786553 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -22,7 +22,7 @@ - + getBlockHtml('formkey') ?> getChildHtml('form_top') ?> hasOptions()):?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js index cf7e73338766..9af5201c267e 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js @@ -42,7 +42,7 @@ require([ return; } product = data.items.find(function (item) { - if (item['item_id'] == itemId) { + if (item['item_id'] === itemId) { return item['product_id'] === productId || item['item_id'] === productId; } diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js index 6eeb61548f92..37b7c7c41b21 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js @@ -8,11 +8,11 @@ define([ var selectors = { formSelector: '#product_addtocart_form', productIdSelector: '#product_addtocart_form [name="product"]', - itemIdSelector:'#product_addtocart_form [name="item"]' + itemIdSelector: '#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), - itemId= $(selectors.itemIdSelector).val(), + itemId = $(selectors.itemIdSelector).val(), /** * set productOptions according to cart data from customer-data @@ -27,7 +27,7 @@ define([ return false; } changedProductOptions = data.items.find(function (item) { - if (item['item_id'] == itemId) { + if (item['item_id'] === itemId) { return item['product_id'] === productId; } }); From c3a1415719f266390593b5a3ee5f35e504c8128e Mon Sep 17 00:00:00 2001 From: Valerij Ivashchenko Date: Fri, 13 Apr 2018 19:49:47 +0300 Subject: [PATCH 5/6] Update validation.js Fix to allow use decimals less then 1 in subproducts qty. --- lib/web/mage/validation/validation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/validation/validation.js b/lib/web/mage/validation/validation.js index 7c082880d94b..f3b36fa153c3 100644 --- a/lib/web/mage/validation/validation.js +++ b/lib/web/mage/validation/validation.js @@ -30,7 +30,7 @@ if (val && val.length > 0) { result = true; - valInt = parseInt(val, 10) || 0; + valInt = parseFloat(val) || 0; if (valInt >= 0) { total += valInt; From 7241aa48f049101c551062cb0ce94ddf9f6e6cd9 Mon Sep 17 00:00:00 2001 From: AlexandrKozyr Date: Fri, 15 Dec 2017 17:07:53 +0200 Subject: [PATCH 6/6] magento/magento2#4389 Widget cache error - fixed CacheKey assignment --- .../Block/Product/ProductsList.php | 4 +++- .../Unit/Block/Product/ProductsListTest.php | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php index 0c9b47f6fa6d..9a55f981b760 100644 --- a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php +++ b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php @@ -167,7 +167,9 @@ public function getCacheKeyInfo() intval($this->getRequest()->getParam($this->getData('page_var_name'), 1)), $this->getProductsPerPage(), $conditions, - $this->json->serialize($this->getRequest()->getParams()) + $this->json->serialize($this->getRequest()->getParams()), + $this->getTemplate(), + $this->getTitle() ]; } diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php index 2ac222bf8267..3039066ad138 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php @@ -87,8 +87,8 @@ protected function setUp() { $this->collectionFactory = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor()->getMock(); + ->setMethods(['create']) + ->disableOriginalConstructor()->getMock(); $this->visibility = $this->getMockBuilder(\Magento\Catalog\Model\Product\Visibility::class) ->setMethods(['getVisibleInCatalogIds']) ->disableOriginalConstructor() @@ -144,6 +144,8 @@ public function testGetCacheKeyInfo() $this->productsList->setData('conditions', 'some_serialized_conditions'); $this->productsList->setData('page_var_name', 'page_number'); + $this->productsList->setTemplate('test_template'); + $this->productsList->setData('title', 'test_title'); $this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1); $this->request->expects($this->once())->method('getParams')->willReturn('request_params'); @@ -166,7 +168,9 @@ public function testGetCacheKeyInfo() 1, 5, 'some_serialized_conditions', - json_encode('request_params') + json_encode('request_params'), + 'test_template', + 'test_title' ]; $this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo()); } @@ -251,9 +255,10 @@ public function testGetPagerHtml() * Test public `createCollection` method and protected `getPageSize` method via `createCollection` * * @param bool $pagerEnable - * @param int $productsCount - * @param int $productsPerPage - * @param int $expectedPageSize + * @param int $productsCount + * @param int $productsPerPage + * @param int $expectedPageSize + * * @dataProvider createCollectionDataProvider */ public function testCreateCollection($pagerEnable, $productsCount, $productsPerPage, $expectedPageSize) @@ -382,6 +387,7 @@ public function testGetIdentities() /** * @param $collection + * * @return \PHPUnit_Framework_MockObject_MockObject */ private function getConditionsForCollection($collection)