Skip to content

Commit c3e897c

Browse files
committed
MC-36779: Product still present in the Wish List after added to order
1 parent 07cd2ed commit c3e897c

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ public function applySidebarData($data)
970970
$item = $this->getCustomerCart()->getItemById($itemId);
971971
if ($item) {
972972
$this->moveQuoteItem($item, 'order', $qty);
973-
$data['remove'][$itemId] = 'cart';
973+
$this->removeItem($itemId, 'cart');
974974
}
975975
}
976976
}
@@ -984,7 +984,7 @@ public function applySidebarData($data)
984984
);
985985
if ($item->getId()) {
986986
$this->addProduct($item->getProduct(), $item->getBuyRequest()->toArray());
987-
$data['remove'][$itemId] = 'wishlist';
987+
$this->removeItem($itemId, 'wishlist');
988988
}
989989
}
990990
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,18 @@
136136
<see selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInWishList"/>
137137
<see selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$createConfigProduct.name$$" stepKey="seeConfigurableProductInWishList"/>
138138

139-
<!-- Add products to order from Wish List -->
139+
<!-- Move products to order from Wish List -->
140140
<waitForElementVisible selector="{{AdminCreateOrderWishListSection.addProductToOrderCheckBox($$simpleProduct.name$$)}}" stepKey="waitForCheckBoxToVisible"/>
141141
<click selector="{{AdminCreateOrderWishListSection.addProductToOrderCheckBox($$simpleProduct.name$$)}}" stepKey="selectProductToAddToOrder"/>
142+
<click selector="{{AdminCustomerCreateNewOrderSection.updateChangesBtn}}" stepKey="clickOnUpdateButton"/>
142143
<click selector="{{AdminCreateOrderWishListSection.addConfigProductToOrder($$createConfigProduct.name$$)}}" stepKey="AddConfigurableProductToOrder"/>
143144
<waitForElementVisible selector="{{AdminOrderFormConfigureProductSection.optionSelect($$createConfigProductAttribute.default_frontend_label$$)}}" stepKey="waitForConfigurablePopover"/>
144145
<selectOption selector="{{AdminOrderFormConfigureProductSection.optionSelect($$createConfigProductAttribute.default_frontend_label$$)}}" userInput="$$getConfigAttributeOption1.label$$" stepKey="selectConfigurableOption"/>
145146
<click selector="{{AdminOrderFormConfigureProductSection.ok}}" stepKey="clickOkButton"/>
146-
<click selector="{{AdminCustomerCreateNewOrderSection.updateChangesBtn}}" stepKey="clickOnUpdateButton"/>
147-
<waitForPageLoad stepKey="waitForAdminOrderItemsOrderedSectionPageLoad1"/>
147+
148+
<!-- After move, assert products are NOT present in Wish List section -->
149+
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$simpleProduct.name$" stepKey="dontSeeSimpleProductInWishList"/>
150+
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$createConfigProduct.name$" stepKey="dontSeeConfigurableProductInWishList"/>
148151

149152
<!-- Assert Products in Order item section -->
150153
<see selector="{{AdminOrderItemsOrderedSection.productName}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInOrderItemGrid"/>
@@ -171,10 +174,6 @@
171174
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct.name$$" stepKey="donSeeProductInShoppingCart"/>
172175
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct1.name$$" stepKey="dontSeeSecondProductInShoppingCart"/>
173176

174-
<!-- After move, assert products are present in Wish List section -->
175-
<see selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInWishList1"/>
176-
<see selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$createConfigProduct.name$$" stepKey="seeConfigurableProductInWishList1"/>
177-
178177
<!-- After move, assert products are present in order items section -->
179178
<see selector="{{AdminOrderItemsOrderedSection.productName}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInOrderItemGrid1"/>
180179
<see selector="{{AdminOrderItemsOrderedSection.productName}}" userInput="$$createConfigProduct.name$$" stepKey="seeConfigProductInOrderItemGrid1"/>

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,8 @@ define([
942942
*/
943943
sidebarConfigureProduct: function (listType, productId, itemId) {
944944
// create additional fields
945-
var params = {};
945+
var params = {},
946+
isWishlist = !!itemId;
946947
params.reset_shipping = true;
947948
params.add_product = productId;
948949
this.prepareParams(params);
@@ -963,10 +964,18 @@ define([
963964
}.bind(this));
964965
// response handler
965966
productConfigure.setOnLoadIFrameCallback(listType, function (response) {
967+
var area = ['items', 'shipping_method', 'billing_method', 'totals', 'giftmessage'];
968+
966969
if (!response.ok) {
967970
return;
968971
}
969-
this.loadArea(['items', 'shipping_method', 'billing_method', 'totals', 'giftmessage'], true);
972+
if (isWishlist) {
973+
this.removeSidebarItem(itemId, 'wishlist').done(function () {
974+
this.loadArea(area, true);
975+
}.bind(this));
976+
} else {
977+
this.loadArea(area, true);
978+
}
970979
}.bind(this));
971980
// show item configuration
972981
itemId = itemId ? itemId : productId;
@@ -975,7 +984,10 @@ define([
975984
},
976985

977986
removeSidebarItem: function (id, from) {
978-
this.loadArea(['sidebar_' + from], 'sidebar_data_' + from, {remove_item: id, from: from});
987+
return this.loadArea(['sidebar_' + from], 'sidebar_data_' + from, {
988+
remove_item: id,
989+
from: from
990+
});
979991
},
980992

981993
itemsUpdate: function () {

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testAddProductToOrderFromWishList(): void
225225
$params = $this->hydrateParams();
226226
$this->dispatchWitParams($params, $post);
227227

228-
$wishlistItems->clear();
228+
$wishlistItems->clear()->load();
229229
$this->assertEmpty($wishlistItems);
230230
$quoteItems = $this->session->getQuote()->getItemsCollection();
231231
$this->assertCount(1, $quoteItems);

0 commit comments

Comments
 (0)