Skip to content

Commit 41565f0

Browse files
committed
MC-22856: Disable product issue with Cart Item bundle product
- Fix issue with checkout button not showing if bundle product was disabled
1 parent e34c795 commit 41565f0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1212
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
13+
use Magento\Framework\Exception\NoSuchEntityException;
1314
use Magento\Quote\Model\Quote;
1415
use Magento\Quote\Model\Quote\Item as QuoteItem;
1516
use Magento\Quote\Model\ResourceModel\Quote\Item as ResourceQuoteItem;
@@ -256,8 +257,17 @@ protected function _assignProducts(): self
256257
foreach ($this as $item) {
257258
/** @var ProductInterface $product */
258259
$product = $productCollection->getItemById($item->getProductId());
260+
try {
261+
/** @var QuoteItem $item */
262+
$parentItem = $item->getParentItem();
263+
$parentProduct = $parentItem ? $parentItem->getProduct() : null;
264+
} catch (NoSuchEntityException $exception) {
265+
$parentItem = null;
266+
$parentProduct = null;
267+
$this->_logger->error($exception);
268+
}
259269
$qtyOptions = [];
260-
if ($product && $this->isValidProduct($product)) {
270+
if ($this->isValidProduct($product) && (!$parentItem || $this->isValidProduct($parentProduct))) {
261271
$product->setCustomOptions([]);
262272
$optionProductIds = $this->getOptionProductIds($item, $product, $productCollection);
263273
foreach ($optionProductIds as $optionProductId) {
@@ -327,7 +337,7 @@ private function getOptionProductIds(
327337
* @param ProductInterface $product
328338
* @return bool
329339
*/
330-
private function isValidProduct(ProductInterface $product): bool
340+
private function isValidProduct(?ProductInterface $product): bool
331341
{
332342
$result = ($product && (int)$product->getStatus() !== ProductStatus::STATUS_DISABLED);
333343

0 commit comments

Comments
 (0)