Skip to content

Commit 2504806

Browse files
committed
Merge remote-tracking branch 'origin/imported-magento-magento2-31110' into 2.4-develop-pr113
2 parents 915fe70 + 44809b9 commit 2504806

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ public function applySidebarData($data)
984984
);
985985
if ($item->getId()) {
986986
$this->addProduct($item->getProduct(), $item->getBuyRequest()->toArray());
987+
$this->removeItem($itemId, 'wishlist');
987988
}
988989
}
989990
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@
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="clickUpdateChangesButton"/>
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+
<comment userInput="Action should be removed but replaced with comment due to backward compatibility" stepKey="clickOnUpdateButton"/>
147148
<waitForPageLoad stepKey="waitForAdminOrderItemsOrderedSectionPageLoad1"/>
148149

149150
<!-- Assert Products in Order item section -->
@@ -171,9 +172,9 @@
171172
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct.name$$" stepKey="donSeeProductInShoppingCart"/>
172173
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct1.name$$" stepKey="dontSeeSecondProductInShoppingCart"/>
173174

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"/>
175+
<!-- After move, assert products are not present in Wish List section -->
176+
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInWishList1"/>
177+
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$createConfigProduct.name$$" stepKey="seeConfigurableProductInWishList1"/>
177178

178179
<!-- After move, assert products are present in order items section -->
179180
<see selector="{{AdminOrderItemsOrderedSection.productName}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInOrderItemGrid1"/>

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 areas = ['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(areas, true);
975+
}.bind(this));
976+
} else {
977+
this.loadArea(areas, 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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Store\Model\StoreManagerInterface;
1717
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
1818
use Magento\TestFramework\TestCase\AbstractBackendController;
19+
use Magento\Wishlist\Model\Wishlist;
1920

2021
/**
2122
* Class checks create order load block controller.
@@ -201,6 +202,35 @@ public function testMoveFromOrderToShoppingCart(): void
201202
$this->quoteIdsToRemove[] = $customerCart->getId();
202203
}
203204

205+
/**
206+
* Check that Wishlist item is deleted after it has been added to Order.
207+
*
208+
* @return void
209+
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
210+
*/
211+
public function testAddProductToOrderFromWishList(): void
212+
{
213+
/** @var Wishlist $wishlist */
214+
$wishlist = $this->_objectManager->create(Wishlist::class);
215+
$wishlistItems = $wishlist->loadByCustomerId(1)->getItemCollection();
216+
$this->assertCount(1, $wishlistItems);
217+
218+
$post = $this->hydratePost([
219+
'sidebar' => [
220+
'add_wishlist_item' => [
221+
$wishlistItems->getFirstItem()->getId() => 1,
222+
],
223+
],
224+
]);
225+
$params = $this->hydrateParams();
226+
$this->dispatchWitParams($params, $post);
227+
228+
$wishlistItems->clear()->load();
229+
$this->assertEmpty($wishlistItems);
230+
$quoteItems = $this->session->getQuote()->getItemsCollection();
231+
$this->assertCount(1, $quoteItems);
232+
}
233+
204234
/**
205235
* Check customer quotes
206236
*

0 commit comments

Comments
 (0)