Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2025 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand All @@ -10,6 +10,8 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\CatalogInventory\Model\ResourceModel\Stock\StatusFactory;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\Exception\LocalizedException;

/**
Expand All @@ -27,16 +29,24 @@ class Variant
*/
private $stockStatusFactory;

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param Configurable $configurableType
* @param StatusFactory $stockStatusFactory
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Configurable $configurableType,
StatusFactory $stockStatusFactory
StatusFactory $stockStatusFactory,
ScopeConfigInterface $scopeConfig
) {
$this->configurableType = $configurableType;
$this->stockStatusFactory = $stockStatusFactory;
$this->scopeConfig = $scopeConfig;
}

/**
Expand All @@ -56,8 +66,12 @@ public function getSalableVariantsByParent(ProductInterface $product): array
$stockFlag = 'has_stock_status_filter';
if (!$collection->hasFlag($stockFlag)) {
$stockStatusResource = $this->stockStatusFactory->create();
$stockStatusResource->addStockDataToCollection($collection, true);
$collection->setFlag($stockFlag, true);
$showOutOfStock = $this->scopeConfig->isSetFlag(
'cataloginventory/options/show_out_of_stock',
ScopeInterface::SCOPE_STORE
);
$stockStatusResource->addStockDataToCollection($collection, !$showOutOfStock);
$collection->setFlag($stockFlag, !$showOutOfStock);
}
$collection->addMediaGalleryData();
$collection->addTierPriceData();
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/ConfigurableProductGraphQl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"magento/module-quote": "*",
"magento/module-quote-graph-ql": "*",
"magento/module-catalog-inventory": "*",
"magento/module-store": "*",
"magento/framework": "*"
},
"license": [
Expand Down