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 ;
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