88namespace Magento \Sales \Controller \Adminhtml \Order ;
99
1010use Magento \Backend \App \Action ;
11+ use Magento \Catalog \Model \Product ;
1112use Magento \Framework \App \ObjectManager ;
1213use Magento \Framework \View \Result \PageFactory ;
1314use Magento \Backend \Model \View \Result \ForwardFactory ;
1415use Magento \Sales \Model \Order \Create \ValidateCoupon ;
16+ use Magento \Catalog \Api \ProductRepositoryInterface ;
1517
1618/**
1719 * Adminhtml sales orders creation process controller
@@ -54,6 +56,11 @@ abstract class Create extends \Magento\Backend\App\Action
5456 */
5557 private $ validateCoupon ;
5658
59+ /**
60+ * @var ProductRepositoryInterface
61+ */
62+ private ProductRepositoryInterface $ productRepository ;
63+
5764 /**
5865 * @param Action\Context $context
5966 * @param \Magento\Catalog\Helper\Product $productHelper
@@ -68,13 +75,16 @@ public function __construct(
6875 \Magento \Framework \Escaper $ escaper ,
6976 PageFactory $ resultPageFactory ,
7077 ForwardFactory $ resultForwardFactory ,
78+ ?ProductRepositoryInterface $ productRepository = null ,
7179 ?ValidateCoupon $ validateCoupon = null
7280 ) {
7381 parent ::__construct ($ context );
7482 $ productHelper ->setSkipSaleableCheck (true );
7583 $ this ->escaper = $ escaper ;
7684 $ this ->resultPageFactory = $ resultPageFactory ;
7785 $ this ->resultForwardFactory = $ resultForwardFactory ;
86+ $ this ->productRepository = $ productRepository ?: ObjectManager::getInstance ()
87+ ->get (ProductRepositoryInterface::class);
7888 $ this ->validateCoupon = $ validateCoupon ?: ObjectManager::getInstance ()->get (ValidateCoupon::class);
7989 }
8090
@@ -281,11 +291,8 @@ function ($v) {
281291 }
282292 if ($ this ->_getQuote ()->hasProductId ((int )$ productId ) && !$ hasOptionsInConfig ) {
283293 try {
284- /** @var \Magento\Catalog\Model\Product $product */
285- $ product = $ this
286- ->_objectManager
287- ->create (\Magento \Catalog \Model \Product::class)
288- ->load ($ productId );
294+ /** @var Product $product */
295+ $ product = $ this ->productRepository ->getById ($ productId );
289296 if ($ product ->getId () && $ product ->getHasOptions ()) {
290297 $ hasRequired = false ;
291298 foreach ($ product ->getOptions () as $ option ) {
0 commit comments