-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
1 deletion.
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
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
53 changes: 53 additions & 0 deletions
53
...sts/api-functional/testsuite/Magento/GraphQl/Quote/GetEmptyOptionsValuesForQueryBySku.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,53 @@ | ||
<?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\ProductCustomOptionRepositoryInterface; | ||
|
||
/** | ||
* Generate an array with test values for customizable options based on the option type | ||
*/ | ||
class GetEmptyOptionsValuesForQueryBySku | ||
{ | ||
/** | ||
* @var ProductCustomOptionRepositoryInterface | ||
*/ | ||
private $productCustomOptionRepository; | ||
|
||
/** | ||
* @param ProductCustomOptionRepositoryInterface $productCustomOptionRepository | ||
*/ | ||
public function __construct(ProductCustomOptionRepositoryInterface $productCustomOptionRepository) | ||
{ | ||
$this->productCustomOptionRepository = $productCustomOptionRepository; | ||
} | ||
|
||
/** | ||
* Returns array of empty options for the product | ||
* | ||
* @param string $sku | ||
* @return array | ||
*/ | ||
public function execute(string $sku): array | ||
{ | ||
$customOptions = $this->productCustomOptionRepository->getList($sku); | ||
$customOptionsValues = []; | ||
|
||
foreach ($customOptions as $customOption) { | ||
$optionType = $customOption->getType(); | ||
if ($optionType == 'date') { | ||
$customOptionsValues[] = [ | ||
'id' => (int)$customOption->getOptionId(), | ||
'value_string' => '' | ||
]; | ||
} | ||
} | ||
|
||
return $customOptionsValues; | ||
} | ||
} |