Skip to content

Commit 72ea82d

Browse files
AnujNehraAnujNehra
authored andcommitted
ACP2E-1975: GraphQL cannot add product with customizable option to cart
1 parent 2fd24bd commit 72ea82d

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

app/code/Magento/Quote/Model/Cart/AddProductsToCart.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function addItemToCart(Quote $cart, Data\CartItem $cartItem, int $cartIt
168168
$cartItemPosition
169169
);
170170
} else {
171-
$product = $this->getProductOptions($this->productReader->getProductBySku($sku));
171+
$product = $this->productReader->getProductBySku($sku);
172172
if (!$product || !$product->isSaleable() || !$product->isAvailable()) {
173173
$errors[] = $this->error->create(
174174
__('Could not find a product with SKU "%sku"', ['sku' => $sku])->render(),
@@ -209,16 +209,4 @@ private function prepareErrorOutput(Quote $cart, array $errors = []): AddProduct
209209

210210
return $output;
211211
}
212-
213-
/**
214-
* Set options from product options collection
215-
*
216-
* @param ProductInterface|null $productItem
217-
* @return ProductInterface|null
218-
*/
219-
private function getProductOptions(ProductInterface|null $productItem): ?ProductInterface
220-
{
221-
$productItem?->setOptions($productItem->getProductOptionsCollection()->getItems());
222-
return $productItem;
223-
}
224212
}

app/code/Magento/Quote/Model/Cart/ProductReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function loadProducts(array $skus, int $storeId): void
6262
$this->productCollection->addFieldToFilter(ProductInterface::SKU, ['in' => $skus]);
6363
$this->productCollection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
6464
$this->productCollection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
65+
$this->productCollection->addOptionsToResult();
6566
$this->productCollection->load();
6667
foreach ($this->productCollection->getItems() as $productItem) {
6768
$this->productsBySku[$productItem->getData(ProductInterface::SKU)] = $productItem;

0 commit comments

Comments
 (0)