Skip to content

Commit

Permalink
Merge pull request #98 from IrinaZhadzinets/issue-2685
Browse files Browse the repository at this point in the history
#2685 - Revert previous solution
  • Loading branch information
carinadues authored Jun 9, 2022
2 parents e6f2df4 + 0197a59 commit 96ea1c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
15 changes: 2 additions & 13 deletions src/Model/Resolver/ExpandedOrderResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use ScandiPWA\QuoteGraphQl\Model\Customer\CheckCustomerAccount;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Sales\Model\OrderRepository;
use Magento\Customer\Api\CustomerRepositoryInterface;

/**
* Orders data resolver
Expand All @@ -43,27 +42,19 @@ class ExpandedOrderResolver implements ResolverInterface
*/
protected $orderRepository;

/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;

/**
* @param CollectionFactoryInterface $collectionFactory
* @param CheckCustomerAccount $checkCustomerAccount
* @param OrderRepository $orderRepository
* @param CustomerRepositoryInterface $customerRepository
*/
public function __construct(
CollectionFactoryInterface $collectionFactory,
CheckCustomerAccount $checkCustomerAccount,
OrderRepository $orderRepository,
CustomerRepositoryInterface $customerRepository
OrderRepository $orderRepository
) {
$this->collectionFactory = $collectionFactory;
$this->checkCustomerAccount = $checkCustomerAccount;
$this->orderRepository = $orderRepository;
$this->customerRepository = $customerRepository;
}

/**
Expand All @@ -85,9 +76,7 @@ public function resolve(
$orderId = $args['id'];
$order = $this->orderRepository->get($orderId);

$customer = $this->customerRepository->getById($customerId);

if ($customerId !== $order->getCustomerId() && $customer->getEmail() !== $order->getCustomerEmail()) {
if ($customerId != $order->getCustomerId()) {
throw new GraphQlNoSuchEntityException(__('Customer ID is invalid.'));
}

Expand Down
26 changes: 4 additions & 22 deletions src/Model/Resolver/OrderListResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* ScandiPWA - Progressive Web App for Magento
*
Expand All @@ -20,7 +19,6 @@
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface;
use ScandiPWA\QuoteGraphQl\Model\Customer\CheckCustomerAccount;
use Magento\Customer\Api\CustomerRepositoryInterface;

/**
* Orders data reslover
Expand All @@ -30,32 +28,23 @@ class OrderListResolver implements ResolverInterface
/**
* @var CollectionFactoryInterface
*/
protected $collectionFactory;
protected CollectionFactoryInterface $collectionFactory;

/**
* @var CheckCustomerAccount
*/
protected $checkCustomerAccount;


/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
protected CheckCustomerAccount $checkCustomerAccount;

/**
* @param CollectionFactoryInterface $collectionFactory
* @param CheckCustomerAccount $checkCustomerAccount
* @param CustomerRepositoryInterface $customerRepository
*/
public function __construct(
CollectionFactoryInterface $collectionFactory,
CheckCustomerAccount $checkCustomerAccount,
CustomerRepositoryInterface $customerRepository
CheckCustomerAccount $checkCustomerAccount
) {
$this->collectionFactory = $collectionFactory;
$this->checkCustomerAccount = $checkCustomerAccount;
$this->customerRepository = $customerRepository;
}

/**
Expand All @@ -74,14 +63,7 @@ public function resolve(

$this->checkCustomerAccount->execute($customerId, $context->getUserType());

$customer = $this->customerRepository->getById($customerId);

$ordersCollection = $this->collectionFactory->create();
$ordersCollection->addFieldToFilter(
['customer_id', 'customer_email'],
[['eq' => $customerId], ['eq' => $customer->getEmail()]]
);
$orders = $ordersCollection->load();
$orders = $this->collectionFactory->create($customerId);

foreach ($orders as $order) {
$trackNumbers = [];
Expand Down

0 comments on commit 96ea1c2

Please sign in to comment.