Skip to content

Commit 2d5e04a

Browse files
committed
Revert "AC-15286::Order creation in backoffice with multiple products of which at least one contains custom options, leads to unwanted extra products to get added to the order"
This reverts commit c5ff367.
1 parent a01f3ac commit 2d5e04a

File tree

1 file changed

+5
-12
lines changed
  • app/code/Magento/Sales/Controller/Adminhtml/Order

1 file changed

+5
-12
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
namespace Magento\Sales\Controller\Adminhtml\Order;
99

1010
use Magento\Backend\App\Action;
11-
use Magento\Catalog\Model\Product;
1211
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\View\Result\PageFactory;
1413
use Magento\Backend\Model\View\Result\ForwardFactory;
1514
use Magento\Sales\Model\Order\Create\ValidateCoupon;
16-
use Magento\Catalog\Api\ProductRepositoryInterface;
1715

1816
/**
1917
* Adminhtml sales orders creation process controller
@@ -56,11 +54,6 @@ abstract class Create extends \Magento\Backend\App\Action
5654
*/
5755
private $validateCoupon;
5856

59-
/**
60-
* @var ProductRepositoryInterface
61-
*/
62-
private ProductRepositoryInterface $productRepository;
63-
6457
/**
6558
* @param Action\Context $context
6659
* @param \Magento\Catalog\Helper\Product $productHelper
@@ -75,16 +68,13 @@ public function __construct(
7568
\Magento\Framework\Escaper $escaper,
7669
PageFactory $resultPageFactory,
7770
ForwardFactory $resultForwardFactory,
78-
?ProductRepositoryInterface $productRepository = null,
7971
?ValidateCoupon $validateCoupon = null
8072
) {
8173
parent::__construct($context);
8274
$productHelper->setSkipSaleableCheck(true);
8375
$this->escaper = $escaper;
8476
$this->resultPageFactory = $resultPageFactory;
8577
$this->resultForwardFactory = $resultForwardFactory;
86-
$this->productRepository = $productRepository ?: ObjectManager::getInstance()
87-
->get(ProductRepositoryInterface::class);
8878
$this->validateCoupon = $validateCoupon ?: ObjectManager::getInstance()->get(ValidateCoupon::class);
8979
}
9080

@@ -291,8 +281,11 @@ function ($v) {
291281
}
292282
if ($this->_getQuote()->hasProductId((int)$productId) && !$hasOptionsInConfig) {
293283
try {
294-
/** @var Product $product */
295-
$product = $this->productRepository->getById($productId);
284+
/** @var \Magento\Catalog\Model\Product $product */
285+
$product = $this
286+
->_objectManager
287+
->create(\Magento\Catalog\Model\Product::class)
288+
->load($productId);
296289
if ($product->getId() && $product->getHasOptions()) {
297290
$hasRequired = false;
298291
foreach ($product->getOptions() as $option) {

0 commit comments

Comments
 (0)