Skip to content

Commit c31fdcd

Browse files
committed
AC-15054: Product Add to Cart issue in Rest API
1 parent a22d447 commit c31fdcd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/code/Magento/Quote/Plugin/UpdateCartId.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ private function validateWebsiteAssignment(int $productId, int $storeId): void
131131
{
132132
try {
133133
$product = $this->productRepository->getById($productId, false, $storeId);
134+
if (empty($product->getWebsiteIds())) {
135+
return;
136+
}
134137
$this->checkProductInWebsite($product->getWebsiteIds(), $storeId);
135138
} catch (NoSuchEntityException) {
136139
throw new LocalizedException(__('Product that you are trying to add is not available.'));

app/code/Magento/Quote/Plugin/Webapi/ValidateProductWebsiteAssignment.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ private function checkProductWebsiteAssignment($productId, $storeId): void
9797
{
9898
try {
9999
$product = $this->productRepository->getById($productId, false, $storeId);
100+
if (empty($product->getWebsiteIds())) {
101+
return;
102+
}
100103
$this->validateWebsiteAssignment($product->getWebsiteIds(), $storeId);
101104
} catch (NoSuchEntityException $e) {
102105
throw new LocalizedException(__('Product that you are trying to add is not available.'));
@@ -113,7 +116,6 @@ private function checkProductWebsiteAssignment($productId, $storeId): void
113116
private function validateWebsiteAssignment(?array $websiteIds, int $storeId): void
114117
{
115118
$websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
116-
117119
if (empty($websiteIds) || !in_array($websiteId, $websiteIds, true)) {
118120
throw new LocalizedException(__('Product that you are trying to add is not available.'));
119121
}

0 commit comments

Comments
 (0)