Skip to content

Commit 03afb46

Browse files
committed
Reverted multiple/checkbox options fix
1 parent 026e68f commit 03afb46

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\QuoteGraphQl\Model\Cart;
99

10-
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
11-
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
1210
use Magento\Catalog\Api\ProductRepositoryInterface;
1311
use Magento\Framework\DataObject;
1412
use Magento\Framework\DataObjectFactory;
@@ -25,11 +23,6 @@
2523
*/
2624
class AddSimpleProductToCart
2725
{
28-
/**
29-
* @var ProductCustomOptionRepositoryInterface
30-
*/
31-
private $customOptionRepository;
32-
3326
/**
3427
* @var ArrayManager
3528
*/
@@ -49,18 +42,15 @@ class AddSimpleProductToCart
4942
* @param ArrayManager $arrayManager
5043
* @param DataObjectFactory $dataObjectFactory
5144
* @param ProductRepositoryInterface $productRepository
52-
* @param ProductCustomOptionRepositoryInterface $customOptionRepository
5345
*/
5446
public function __construct(
5547
ArrayManager $arrayManager,
5648
DataObjectFactory $dataObjectFactory,
57-
ProductRepositoryInterface $productRepository,
58-
ProductCustomOptionRepositoryInterface $customOptionRepository
49+
ProductRepositoryInterface $productRepository
5950
) {
6051
$this->arrayManager = $arrayManager;
6152
$this->dataObjectFactory = $dataObjectFactory;
6253
$this->productRepository = $productRepository;
63-
$this->customOptionRepository = $customOptionRepository;
6454
}
6555

6656
/**
@@ -77,7 +67,7 @@ public function execute(Quote $cart, array $cartItemData): void
7767
{
7868
$sku = $this->extractSku($cartItemData);
7969
$qty = $this->extractQty($cartItemData);
80-
$customizableOptions = $this->extractCustomizableOptions($cartItemData, $sku);
70+
$customizableOptions = $this->extractCustomizableOptions($cartItemData);
8171

8272
try {
8373
$product = $this->productRepository->get($sku);
@@ -137,23 +127,15 @@ private function extractQty(array $cartItemData): float
137127
* Extract Customizable Options from cart item data
138128
*
139129
* @param array $cartItemData
140-
* @param string $sku
141130
* @return array
142131
*/
143-
private function extractCustomizableOptions(array $cartItemData, string $sku): array
132+
private function extractCustomizableOptions(array $cartItemData): array
144133
{
145134
$customizableOptions = $this->arrayManager->get('customizable_options', $cartItemData, []);
146-
$productCustomOptions = $this->customOptionRepository->getList($sku);
147-
$productCustomOptionsMap = $this->getProductCustomOptionsMap($productCustomOptions);
148-
$customizableOptionsData = [];
149135

136+
$customizableOptionsData = [];
150137
foreach ($customizableOptions as $customizableOption) {
151-
$multipleOptionTypesList = ['multiple', 'checkbox']; // TODO: use constants
152-
if (in_array($productCustomOptionsMap[$customizableOption['id']]->getType(), $multipleOptionTypesList)) {
153-
$customizableOptionsData[$customizableOption['id']] = explode(',', $customizableOption['value']);
154-
} else {
155-
$customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
156-
}
138+
$customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
157139
}
158140
return $customizableOptionsData;
159141
}
@@ -174,21 +156,4 @@ private function createBuyRequest(float $qty, array $customOptions): DataObject
174156
],
175157
]);
176158
}
177-
178-
/**
179-
* Creates an array with a key equals option ID
180-
*
181-
* @param array $productCustomOptions
182-
* @return array
183-
*/
184-
private function getProductCustomOptionsMap(array $productCustomOptions): array
185-
{
186-
$customOptionsData = [];
187-
/** @var ProductCustomOptionInterface $productCustomOption */
188-
foreach ($productCustomOptions as $productCustomOption) {
189-
$customOptionsData[$productCustomOption->getOptionId()] = $productCustomOption;
190-
}
191-
192-
return $customOptionsData;
193-
}
194159
}

0 commit comments

Comments
 (0)