Skip to content

Commit 71ae5db

Browse files
committed
MC-36779: Product still present in the Wish List after added to order
1 parent 479f304 commit 71ae5db

File tree

2 files changed

+32
-1
lines changed
  • app/code/Magento/Sales/Model/AdminOrder
  • dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create

2 files changed

+32
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
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-
$this->removeItem($itemId, 'cart');
973+
$data['remove'][$itemId] = 'cart';
974974
}
975975
}
976976
}
@@ -984,6 +984,7 @@ public function applySidebarData($data)
984984
);
985985
if ($item->getId()) {
986986
$this->addProduct($item->getProduct(), $item->getBuyRequest()->toArray());
987+
$data['remove'][$itemId] = 'wishlist';
987988
}
988989
}
989990
}

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();
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)