Skip to content

Commit a095bb6

Browse files
committed
ACP2E-3563: Issue while moving the product qty to back to shopping cart from the admin
1 parent 7b8064f commit a095bb6

File tree

7 files changed

+20
-30
lines changed

7 files changed

+20
-30
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -15,7 +15,6 @@
1515
* Adminhtml sales order create sidebar cart block
1616
*
1717
* @api
18-
* @author Magento Core Team <core@magentocommerce.com>
1918
* @since 100.0.2
2019
*/
2120
class Cart extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar
@@ -59,16 +58,6 @@ public function getItemCollection()
5958
$collection = $this->getData('item_collection');
6059
if ($collection === null) {
6160
$collection = $this->getCreateOrderModel()->getCustomerCart()->getAllVisibleItems();
62-
$transferredItems = $this->getCreateOrderModel()->getSession()->getTransferredItems() ?? [];
63-
$transferredItems = $transferredItems[$this->getDataId()] ?? [];
64-
if (!empty($transferredItems)) {
65-
foreach ($collection as $key => $item) {
66-
if (in_array($item->getId(), $transferredItems)) {
67-
unset($collection[$key]);
68-
}
69-
}
70-
}
71-
7261
$this->setData('item_collection', $collection);
7362
}
7463
return $collection;

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,25 +2359,22 @@ private function formattedOptions(\Magento\Catalog\Model\Product $product, $buyR
23592359
}
23602360

23612361
/**
2362-
* Remove cart from transferred items and update the qty.
2362+
* Remove cart from transferred items
23632363
*
23642364
* @param int|null|Item $cartItem
23652365
* @param int $itemId
23662366
* @return void
2367+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2368+
* @see AC-14442
23672369
*/
23682370
private function removeCartTransferredItemsAndUpdateQty(int|null|Item $cartItem, int $itemId)
23692371
{
23702372
$removeCartTransferredItems = $this->getSession()->getTransferredItems() ?? [];
23712373
if (isset($removeCartTransferredItems['cart'])) {
23722374
$removeTransferredItemKey = array_search($cartItem->getId(), $removeCartTransferredItems['cart']);
2373-
if ($removeCartTransferredItems['cart'][$removeTransferredItemKey]) {
2375+
if ($removeTransferredItemKey !== false && $removeCartTransferredItems['cart'][$removeTransferredItemKey]) {
23742376
$cartItem->clearMessage();
23752377
$cartItem->setHasError(false);
2376-
if (isset($this->request->get('item')[$itemId]['qty'])) {
2377-
$qty = $this->request->get('item')[$itemId]['qty'];
2378-
$cartItem->setQty($qty);
2379-
}
2380-
23812378
if ($cartItem->getHasError()) {
23822379
throw new LocalizedException(__($cartItem->getMessage()));
23832380
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@
182182
<actionGroup ref="AdminClickUpdateChangesOnCreateOrderPageActionGroup" stepKey="clickOnUpdateButton1"/>
183183
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForAdminCreateOrderShoppingCartSectionPageLoad1"/>
184184

185-
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct.name$$" stepKey="donSeeProductInShoppingCart"/>
186-
<dontSee selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct1.name$$" stepKey="dontSeeSecondProductInShoppingCart"/>
185+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="donSeeProductInShoppingCart"/>
186+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="dontSeeSecondProductInShoppingCart"/>
187+
<see selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct.name$$" stepKey="seeProductInShoppingCart2"/>
188+
<see selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="$$simpleProduct1.name$$" stepKey="seeSecondProductInShoppingCart2"/>
187189

188190
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$simpleProduct.name$$" stepKey="seeSimpleProductInWishList1"/>
189191
<dontSee selector="{{AdminCreateOrderWishListSection.wishListBlock}}" userInput="$$createConfigProduct.name$$" stepKey="seeConfigurableProductInWishList1"/>

app/code/Magento/Sales/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ Subtotal:,Subtotal:
528528
Refresh,Refresh
529529
Item,Item
530530
"Add To Order","Add To Order"
531+
"Add to the new order", "Add to the new order"
531532
"Configure and Add to Order","Configure and Add to Order"
532533
"No items","No items"
533534
"Append Comments","Append Comments"

app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2025 Adobe
3+
* Copyright 2013 Adobe
44
* All Rights Reserved.
55
*/
66

@@ -64,9 +64,9 @@ $sideBarPermissionCheck = $block->getData('sideBarPermissionCheck');
6464
<?php endif; ?>
6565

6666
<th class="col-add">
67-
<span title="<?= $escaper->escapeHtml(__('Add To Order')) ?>"
67+
<span title="<?= $escaper->escapeHtml(__('Add to the new order')) ?>"
6868
class="icon icon-add">
69-
<span><?= $escaper->escapeHtml(__('Add To Order')) ?></span>
69+
<span><?= $escaper->escapeHtml(__('Add to the new order')) ?></span>
7070
</span>
7171
</th>
7272
</tr>
@@ -145,7 +145,7 @@ $sideBarPermissionCheck = $block->getData('sideBarPermissionCheck');
145145
name="sidebar[<?= $escaper->escapeHtmlAttr($block->getSidebarStorageAction())
146146
?>][<?= (int) $block->getIdentifierId($_item) ?>]"
147147
value="<?= $block->canDisplayItemQty() ? (float) $_item->getQty() : 1 ?>"
148-
title="<?= $escaper->escapeHtml(__('Add To Order')) ?>"/>
148+
title="<?= $escaper->escapeHtml(__('Add to the new order')) ?>"/>
149149
<label class="admin__field-label"
150150
for="sidebar-<?= $escaper->escapeHtmlAttr($block->getSidebarStorageAction())
151151
?>-<?= (int) $block->getIdentifierId($_item) ?>">

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2020 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -122,7 +122,7 @@ public function testAddProductToOrderFromShoppingCart(bool $asJson, bool $asJsVa
122122
} else {
123123
$body = $this->getResponse()->getBody();
124124
}
125-
$this->assertStringNotContainsString("sidebar[add_cart_item][$itemId]", $body);
125+
$this->assertStringContainsString("sidebar[add_cart_item][$itemId]", $body);
126126
}
127127

128128
/**

dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,15 @@ public function testMoveQuoteItemToCart()
699699
/** @var SessionQuote $session */
700700
$session = $this->objectManager->create(SessionQuote::class);
701701
$session->setCustomerId($fixtureCustomerId);
702-
$session->setTransferredItems(['cart' => [124]]);
702+
703703
/** @var $quoteFixture Quote */
704704
$quoteFixture = $this->objectManager->create(Quote::class);
705705
$quoteFixture->load('test01', 'reserved_order_id');
706706
$quoteFixture->setCustomerIsGuest(false)->setCustomerId($fixtureCustomerId)->save();
707707

708708
$customerQuote = $this->model->getCustomerCart();
709709
$item = $customerQuote->getAllVisibleItems()[0];
710+
$session->setTransferredItems(['cart' => [$item->getId()]]);
710711

711712
$this->model->moveQuoteItem($item, 'cart', 3);
712713
self::assertEquals(4, $item->getQty(), 'Number of Qty isn\'t correct for Quote item.');

0 commit comments

Comments
 (0)