6
6
namespace Magento \Sales \Model ;
7
7
8
8
use Magento \Config \Model \Config \Source \Nooptreq ;
9
+ use Magento \Customer \Api \CustomerRepositoryInterface ;
9
10
use Magento \Directory \Model \Currency ;
10
11
use Magento \Framework \Api \AttributeValueFactory ;
11
12
use Magento \Framework \Api \SearchCriteriaBuilder ;
51
52
* @method bool hasCustomerNoteNotify()
52
53
* @method bool hasForcedCanCreditmemo()
53
54
* @method bool getIsInProcess()
54
- * @method \Magento\Customer\Model\Customer getCustomer()
55
55
* @method \Magento\Sales\Model\Order setSendEmail(bool $value)
56
56
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
57
57
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -307,6 +307,11 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface
307
307
*/
308
308
private $ scopeConfig ;
309
309
310
+ /**
311
+ * @var CustomerRepositoryInterface
312
+ */
313
+ private $ _customerRepositoryInterface ;
314
+
310
315
/**
311
316
* @param \Magento\Framework\Model\Context $context
312
317
* @param \Magento\Framework\Registry $registry
@@ -340,6 +345,7 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface
340
345
* @param OrderItemRepositoryInterface $itemRepository
341
346
* @param SearchCriteriaBuilder $searchCriteriaBuilder
342
347
* @param ScopeConfigInterface $scopeConfig
348
+ * @param CustomerRepositoryInterface $customerRepositoryInterface
343
349
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
344
350
*/
345
351
public function __construct (
@@ -366,6 +372,7 @@ public function __construct(
366
372
\Magento \Sales \Model \ResourceModel \Order \Shipment \Track \CollectionFactory $ trackCollectionFactory ,
367
373
\Magento \Sales \Model \ResourceModel \Order \CollectionFactory $ salesOrderCollectionFactory ,
368
374
PriceCurrencyInterface $ priceCurrency ,
375
+ CustomerRepositoryInterface $ customerRepositoryInterface ,
369
376
\Magento \Catalog \Model \ResourceModel \Product \CollectionFactory $ productListFactory ,
370
377
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
371
378
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
@@ -403,6 +410,7 @@ public function __construct(
403
410
$ this ->searchCriteriaBuilder = $ searchCriteriaBuilder ?: ObjectManager::getInstance ()
404
411
->get (SearchCriteriaBuilder::class);
405
412
$ this ->scopeConfig = $ scopeConfig ?: ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
413
+ $ this ->_customerRepositoryInterface = $ customerRepositoryInterface ;
406
414
407
415
parent ::__construct (
408
416
$ context ,
@@ -562,6 +570,19 @@ public function getStore()
562
570
return $ this ->_storeManager ->getStore ();
563
571
}
564
572
573
+ /**
574
+ * Returns Customer
575
+ *
576
+ * @return \Magento\Customer\Api\Data\CustomerInterface
577
+ * @throws LocalizedException
578
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
579
+ */
580
+ public function getCustomer ()
581
+ {
582
+ $ customerId = $ this ->getData (OrderInterface::CUSTOMER_ID );
583
+ return $ this ->_customerRepositoryInterface ->getById ($ customerId );
584
+ }
585
+
565
586
/**
566
587
* Retrieve order cancel availability
567
588
*
0 commit comments