This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-4704: #544: Replace deprecated fixtures in RemoveItemFromCartT…
…est #545
- Loading branch information
Showing
3 changed files
with
218 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
.../api-functional/testsuite/Magento/GraphQl/Quote/GetQuoteItemIdByReservedQuoteIdAndSku.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\GraphQl\Quote; | ||
|
||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; | ||
use Magento\Quote\Model\QuoteFactory; | ||
|
||
/** | ||
* Get quote item id by reserved order id and product sku | ||
*/ | ||
class GetQuoteItemIdByReservedQuoteIdAndSku | ||
{ | ||
/** | ||
* @var QuoteFactory | ||
*/ | ||
private $quoteFactory; | ||
|
||
/** | ||
* @var QuoteResource | ||
*/ | ||
private $quoteResource; | ||
|
||
/** | ||
* @var ProductRepositoryInterface | ||
*/ | ||
private $productRepository; | ||
|
||
/** | ||
* @param QuoteFactory $quoteFactory | ||
* @param QuoteResource $quoteResource | ||
* @param ProductRepositoryInterface $productRepository | ||
*/ | ||
public function __construct( | ||
QuoteFactory $quoteFactory, | ||
QuoteResource $quoteResource, | ||
ProductRepositoryInterface $productRepository | ||
) { | ||
$this->quoteFactory = $quoteFactory; | ||
$this->quoteResource = $quoteResource; | ||
$this->productRepository = $productRepository; | ||
} | ||
|
||
/** | ||
* Get quote item id by reserved order id and product sku | ||
* | ||
* @param string $reservedOrderId | ||
* @param string $sku | ||
* @return int | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function execute(string $reservedOrderId, string $sku): int | ||
{ | ||
$quote = $this->quoteFactory->create(); | ||
$this->quoteResource->load($quote, $reservedOrderId, 'reserved_order_id'); | ||
$product = $this->productRepository->get($sku); | ||
|
||
return (int)$quote->getItemByProduct($product)->getId(); | ||
} | ||
} |
Oops, something went wrong.