1515use Magento \Framework \View \Result \PageFactory ;
1616use Magento \Backend \Model \View \Result \ForwardFactory ;
1717use 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 = null ;
64+ private ProductRepositoryInterface $ productRepository ;
6565
6666 /**
6767 * @param Context $context
@@ -86,7 +86,8 @@ public function __construct(
8686 $ this ->escaper = $ escaper ;
8787 $ this ->resultPageFactory = $ resultPageFactory ;
8888 $ this ->resultForwardFactory = $ resultForwardFactory ;
89- $ this ->productRepository = $ productRepository ;
89+ $ this ->productRepository = $ productRepository ?: ObjectManager::getInstance ()
90+ ->get (ProductRepositoryInterface::class);
9091 $ this ->validateCoupon = $ validateCoupon ?: ObjectManager::getInstance ()->get (ValidateCoupon::class);
9192 }
9293
@@ -294,13 +295,7 @@ function ($v) {
294295 if ($ this ->_getQuote ()->hasProductId ((int )$ productId ) && !$ hasOptionsInConfig ) {
295296 try {
296297 /** @var Product $product */
297- $ product = ($ this ->productRepository ?: ObjectManager::getInstance ()
298- ->get (ProductRepositoryInterface::class))
299- ->getById (
300- (int )$ productId ,
301- false ,
302- (int )$ this ->_getOrderCreateModel ()->getQuote ()->getStoreId ()
303- );
298+ $ product = $ this ->productRepository ->getById ($ productId );
304299 if ($ product ->getId () && $ product ->getHasOptions ()) {
305300 $ hasRequired = false ;
306301 foreach ($ product ->getOptions () as $ option ) {
0 commit comments