Skip to content

Commit 79418db

Browse files
committed
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
1 parent 6926314 commit 79418db

File tree

1 file changed

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

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\View\Result\PageFactory;
1616
use Magento\Backend\Model\View\Result\ForwardFactory;
1717
use Magento\Sales\Model\Order\Create\ValidateCoupon;
18-
use Magento\Catalog\Api\ProductRepositoryInterface;
18+
use Magento\Catalog\Api\ProductRepositoryInterface;
1919

2020
/**
2121
* Adminhtml sales orders creation process controller
@@ -61,7 +61,7 @@ abstract class Create extends \Magento\Backend\App\Action
6161
/**
6262
* @var ProductRepositoryInterface
6363
*/
64-
private ProductRepositoryInterface $productRepository;
64+
private ?ProductRepositoryInterface $productRepository = null;
6565

6666
/**
6767
* @param Context $context
@@ -86,8 +86,7 @@ public function __construct(
8686
$this->escaper = $escaper;
8787
$this->resultPageFactory = $resultPageFactory;
8888
$this->resultForwardFactory = $resultForwardFactory;
89-
$this->productRepository = $productRepository ?: ObjectManager::getInstance()
90-
->get(ProductRepositoryInterface::class);
89+
$this->productRepository = $productRepository;
9190
$this->validateCoupon = $validateCoupon ?: ObjectManager::getInstance()->get(ValidateCoupon::class);
9291
}
9392

@@ -295,7 +294,13 @@ function ($v) {
295294
if ($this->_getQuote()->hasProductId((int)$productId) && !$hasOptionsInConfig) {
296295
try {
297296
/** @var Product $product */
298-
$product = $this->productRepository->getById($productId);
297+
$product = ($this->productRepository ?: ObjectManager::getInstance()
298+
->get(ProductRepositoryInterface::class))
299+
->getById(
300+
(int)$productId,
301+
false,
302+
(int)$this->_getOrderCreateModel()->getQuote()->getStoreId()
303+
);
299304
if ($product->getId() && $product->getHasOptions()) {
300305
$hasRequired = false;
301306
foreach ($product->getOptions() as $option) {

0 commit comments

Comments
 (0)