Skip to content

Commit 6f49a27

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-73613' into 2.2-develop-pr64
2 parents d946801 + b2a35a8 commit 6f49a27

File tree

9 files changed

+187
-31
lines changed

9 files changed

+187
-31
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<!-- Change Maximum Qty Allowed in Shopping Cart config -->
12+
<entity name="ProductStockOptions" type="catalog_inventory_product_stock_options">
13+
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartChange</requiredEntity>
14+
</entity>
15+
<entity name="MaxQtyAllowInCartChange" type="max_qty_to_cart">
16+
<data key="value">0</data>
17+
</entity>
18+
<!-- Maximum Qty Allowed in Shopping Cart to default config -->
19+
<entity name="DefaultProductStockOptions" type="catalog_inventory_product_stock_options">
20+
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartDefault</requiredEntity>
21+
</entity>
22+
<entity name="MaxQtyAllowInCartDefault" type="max_qty_to_cart">
23+
<data key="value">10000</data>
24+
</entity>
25+
</entities>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
10+
<operation name="CatalogInventoryProductStockSetup" dataType="catalog_inventory_product_stock_options" type="create" auth="adminFormKey" url="/admin/system_config/save/section/cataloginventory/" successRegex="/messages-message-success/" method="POST">
11+
<object key="groups" dataType="catalog_inventory_product_stock_options">
12+
<object key="item_options" dataType="catalog_inventory_product_stock_options">
13+
<object key="fields" dataType="catalog_inventory_product_stock_options">
14+
<object key="max_sale_qty" dataType="max_qty_to_cart">
15+
<field key="value">string</field>
16+
</object>
17+
</object>
18+
</object>
19+
</object>
20+
</operation>
21+
</operations>

app/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<test name="AdminAbleToShipPartiallyInvoicedItemsTest">
1111
<annotations>
1212
<title value="Ship Action is available for remaining of the partially invoiced items "/>
@@ -75,7 +75,7 @@
7575
<waitForElementVisible selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="waitforSubmitInvoiceBtn"/>
7676
<!--Submit Invoice-->
7777
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="submitInvoice"/>
78-
<waitForLoadingMaskToDisappear stepKey="waitForInvoiceToSubmit"/>
78+
<waitForPageLoad stepKey="waitForInvoiceToSubmit1"/>
7979
<!--Invoice created successfully-->
8080
<see selector="{{AdminMessagesSection.success}}" userInput="The invoice has been created." stepKey="seeInvoiceSuccessMessage"/>
8181
<scrollTo selector="{{AdminOrderItemsOrderedSection.itemStatus('1')}}" stepKey="scrollToOrderItems"/>
@@ -136,8 +136,9 @@
136136
<see selector="{{AdminInvoiceItemsSection.itemQty('1')}}" userInput="Refunded 5" stepKey="seeQtyOfItemsRefunded"/>
137137
<!--Submit Invoice-->
138138
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="submitInvoice2" />
139+
<waitForPageLoad stepKey="waitForInvoiceToSubmit2"/>
139140
<!--Invoice created successfully for the rest of the ordered items-->
140-
<see selector="{{AdminMessagesSection.success}}" userInput="The invoice has been created." after="submitInvoice2" stepKey="seeInvoiceSuccessMessage2"/>
141+
<see selector="{{AdminMessagesSection.success}}" userInput="The invoice has been created." stepKey="seeInvoiceSuccessMessage2"/>
141142
<scrollTo selector="{{AdminOrderItemsOrderedSection.itemStatus('1')}}" stepKey="scrollToOrderItems3"/>
142143
<see selector="{{AdminOrderItemsOrderedSection.itemQty('1')}}" userInput="Invoiced 10" stepKey="see10itemsInvoiced"/>
143144
<scrollTo selector="{{AdminHeaderSection.pageTitle}}" stepKey="scrollToTopOfPage3"/>

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Cart.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
88

9+
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
10+
911
/**
1012
* Wishlist block customer item cart column
1113
*
@@ -35,4 +37,28 @@ public function getProductItem()
3537
{
3638
return $this->getItem()->getProduct();
3739
}
40+
41+
/**
42+
* Get min and max qty for wishlist form.
43+
*
44+
* @return array
45+
*/
46+
public function getMinMaxQty(): array
47+
{
48+
$stockItem = $this->stockRegistry->getStockItem(
49+
$this->getItem()->getProduct()->getId(),
50+
$this->getItem()->getProduct()->getStore()->getWebsiteId()
51+
);
52+
53+
$params = [];
54+
55+
$params['minAllowed'] = (float)$stockItem->getMinSaleQty();
56+
if ($stockItem->getMaxSaleQty()) {
57+
$params['maxAllowed'] = (float)$stockItem->getMaxSaleQty();
58+
} else {
59+
$params['maxAllowed'] = (float)StockDataFilter::MAX_QTY_VALUE;
60+
}
61+
62+
return $params;
63+
}
3864
}

app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,21 @@
8787
<click selector="{{StorefrontCustomerWishlistProductSection.productUpdateWishList}}" stepKey="submitUpdateWishlist"/>
8888
<see selector="{{StorefrontMessagesSection.success}}" userInput="{{product.name}} has been updated in your Wish List." stepKey="successMessage"/>
8989
</actionGroup>
90+
91+
<actionGroup name="StorefrontCustomerEditProductInWishlistMakeQuantityValidationError">
92+
<arguments>
93+
<argument name="product"/>
94+
<argument name="description" type="string"/>
95+
<argument name="quantity" type="string"/>
96+
<argument name="errorNum" type="string"/>
97+
</arguments>
98+
<moveMouseOver selector="{{StorefrontCustomerWishlistProductSection.productInfoByName(product.name)}}" stepKey="mouseOverOnProduct" />
99+
<fillField selector="{{StorefrontCustomerWishlistProductSection.productDescription(product.name)}}" userInput="{{description}}" stepKey="fillDescription"/>
100+
<fillField selector="{{StorefrontCustomerWishlistProductSection.productQuantity(product.name)}}" userInput="{{quantity}}" stepKey="fillQuantity"/>
101+
<moveMouseOver selector="{{StorefrontCustomerWishlistProductSection.productAddAllToCart}}" stepKey="mouseOver"/>
102+
<click selector="{{StorefrontCustomerWishlistProductSection.productUpdateWishList}}" stepKey="clickAddToWishlistButton"/>
103+
<moveMouseOver selector="{{StorefrontCustomerWishlistProductSection.productInfoByName(product.name)}}" stepKey="wishlistMoveMouseOverProduct" />
104+
<!--Check error message-->
105+
<see selector="{{StorefrontCustomerWishlistProductSection.productQtyError(product.name)}}" userInput="The maximum you may purchase is {{errorNum}}." stepKey="checkQtyError"/>
106+
</actionGroup>
90107
</actionGroups>

app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<element name="productImageByImageName" type="text" selector="//main//li//a//img[contains(@src, '{{var1}}')]" parameterized="true"/>
1818
<element name="productDescription" type="input" selector="//a[contains(text(), '{{productName}}')]/ancestor::div[@class='product-item-info']//textarea[@class='product-item-comment']" parameterized="true"/>
1919
<element name="productQuantity" type="input" selector="//a[contains(text(), '{{productName}}')]/ancestor::div[@class='product-item-info']//input[@class='input-text qty']" parameterized="true"/>
20+
<element name="productEditButtonByName" type="button" selector="//li[.//a[contains(text(), '{{var1}}')]]//span[contains(text(), 'Edit')]" parameterized="true"/>
2021
<element name="productUpdateWishList" type="button" selector=".column.main .actions-toolbar .action.update" timeout="30"/>
2122
<element name="productAddAllToCart" type="button" selector=".column.main .actions-toolbar .action.tocart" timeout="30"/>
23+
<element name="productQtyError" type="text" selector="//li[.//a[contains(text(), '{{var1}}')]]//div[@class='mage-error']" parameterized="true" timeout="30"/>
2224
</section>
2325
</sections>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCheckAmountLimitWishlistTest">
11+
<annotations>
12+
<stories value="MAGETWO-73613: My Wishlist - quantity input box issue"/>
13+
<title value="Check amount limit for Wishlist"/>
14+
<description value="Check amount limit for Wishlist with different config settings"/>
15+
<features value="Wishlist"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="MAGETWO-96606"/>
18+
<group value="wishlist"/>
19+
</annotations>
20+
<before>
21+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
26+
</before>
27+
<after>
28+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
29+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
30+
<actionGroup ref="CustomerLogoutStorefrontActionGroup" stepKey="logoutCustomerAccount"/>
31+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
32+
<createData entity="DefaultProductStockOptions" stepKey="changeToDefaultQtyAllowAmount"/>
33+
</after>
34+
<!--Login as Customer-->
35+
<actionGroup ref="CustomerLoginOnStorefront" stepKey="loginToStorefrontAccount">
36+
<argument name="customer" value="$$createCustomer$$"/>
37+
</actionGroup>
38+
<!--Go to category page-->
39+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToCreateCategoryPage"/>
40+
<!--Add created product to Wish List-->
41+
<actionGroup ref="StorefrontCustomerAddCategoryProductToWishlistActionGroup" stepKey="addSimpleProduct1ToWishlist">
42+
<argument name="productVar" value="$$createProduct$$"/>
43+
</actionGroup>
44+
<actionGroup ref="StorefrontCustomerEditProductInWishlistMakeQuantityValidationError" stepKey="checkWishListError1">
45+
<argument name="product" value="$$createProduct$$"/>
46+
<argument name="description" value="It`s my dream"/>
47+
<argument name="quantity" value="1234567890"/>
48+
<argument name="errorNum" value="10000"/>
49+
</actionGroup>
50+
<createData entity="ProductStockOptions" stepKey="changeDefaultQtyAllowAmount"/>
51+
<!--Go to wishlist page-->
52+
<amOnPage url="{{StorefrontCustomerWishlistPage.url}}" stepKey="amOnWishlist" />
53+
<actionGroup ref="StorefrontCustomerEditProductInWishlistMakeQuantityValidationError" stepKey="checkWishListError2">
54+
<argument name="product" value="$$createProduct$$"/>
55+
<argument name="description" value="It`s my dream"/>
56+
<argument name="quantity" value="1234567890"/>
57+
<argument name="errorNum" value="99999999"/>
58+
</actionGroup>
59+
</test>
60+
</tests>

app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/** @var \Magento\Wishlist\Model\Item $item */
1212
$item = $block->getItem();
1313
$product = $item->getProduct();
14+
$allowedQty = $block->getMinMaxQty();
1415
?>
1516
<?php foreach ($block->getChildNames() as $childName): ?>
1617
<?= /* @noEscape */ $block->getLayout()->renderElement($childName, false) ?>
@@ -21,7 +22,7 @@ $product = $item->getProduct();
2122
<div class="field qty">
2223
<label class="label" for="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]"><span><?= $block->escapeHtml(__('Qty')) ?></span></label>
2324
<div class="control">
24-
<input type="number" data-role="qty" id="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]" class="input-text qty" data-validate="{'required-number':true,'validate-greater-than-zero':true}"
25+
<input type="number" data-role="qty" id="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]" class="input-text qty" data-validate="{'required-number':true,'validate-greater-than-zero':true, 'validate-item-quantity':{'minAllowed':<?= /* @noEscape */ $allowedQty['minAllowed'] ?>,'maxAllowed':<?= /* @noEscape */ $allowedQty['maxAllowed'] ?>}}"
2526
name="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]" value="<?= /* @noEscape */ (int)($block->getAddToCartQty($item) * 1) ?>">
2627
</div>
2728
</div>

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ define([
6363
isFileUploaded = false,
6464
self = this;
6565

66-
if (event.handleObj.selector == this.options.qtyInfo) { //eslint-disable-line eqeqeq
67-
this._updateAddToWishlistButton({});
68-
event.stopPropagation();
69-
70-
return;
71-
}
7266
$(event.handleObj.selector).each(function (index, element) {
7367
if ($(element).is('input[type=text]') ||
7468
$(element).is('input[type=email]') ||
@@ -89,9 +83,7 @@ define([
8983
}
9084
});
9185

92-
if (isFileUploaded) {
93-
this.bindFormSubmit();
94-
}
86+
this.bindFormSubmit(isFileUploaded);
9587
this._updateAddToWishlistButton(dataToAdd);
9688
event.stopPropagation();
9789
},
@@ -195,34 +187,45 @@ define([
195187

196188
/**
197189
* Bind form submit.
190+
*
191+
* @param {Boolean} isFileUploaded
198192
*/
199-
bindFormSubmit: function () {
193+
bindFormSubmit: function (isFileUploaded) {
200194
var self = this;
201195

202196
$('[data-action="add-to-wishlist"]').on('click', function (event) {
203197
var element, params, form, action;
204198

205-
event.stopPropagation();
206-
event.preventDefault();
199+
if (!$($(self.options.qtyInfo).closest('form')).valid()) {
200+
event.stopPropagation();
201+
event.preventDefault();
207202

208-
element = $('input[type=file]' + self.options.customOptionsInfo);
209-
params = $(event.currentTarget).data('post');
210-
form = $(element).closest('form');
211-
action = params.action;
212-
213-
if (params.data.id) {
214-
$('<input>', {
215-
type: 'hidden',
216-
name: 'id',
217-
value: params.data.id
218-
}).appendTo(form);
203+
return;
219204
}
220205

221-
if (params.data.uenc) {
222-
action += 'uenc/' + params.data.uenc;
223-
}
206+
if (isFileUploaded) {
224207

225-
$(form).attr('action', action).submit();
208+
element = $('input[type=file]' + self.options.customOptionsInfo);
209+
params = $(event.currentTarget).data('post');
210+
form = $(element).closest('form');
211+
action = params.action;
212+
213+
if (params.data.id) {
214+
$('<input>', {
215+
type: 'hidden',
216+
name: 'id',
217+
value: params.data.id
218+
}).appendTo(form);
219+
}
220+
221+
if (params.data.uenc) {
222+
action += 'uenc/' + params.data.uenc;
223+
}
224+
225+
$(form).attr('action', action).submit();
226+
event.stopPropagation();
227+
event.preventDefault();
228+
}
226229
});
227230
}
228231
});

0 commit comments

Comments
 (0)