Skip to content

Commit 3c9ff7a

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-4220' into PR_2025_11_04_flowers
2 parents 51c281c + 2f39641 commit 3c9ff7a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Model\ResourceModel\Indexer;
9+
10+
use Zend_Db_Expr;
11+
12+
class OptionQtyExpressionProvider
13+
{
14+
/**
15+
* Get expression for calculating available quantity for bundle option.
16+
*
17+
* @return Zend_Db_Expr
18+
*/
19+
public function getExpression(): Zend_Db_Expr
20+
{
21+
return new Zend_Db_Expr('i.qty - cisi.min_qty');
22+
}
23+
}

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Stock.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Bundle\Model\ResourceModel\Indexer;
99

10+
use Magento\Bundle\Model\Product\Type;
1011
use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
1112
use Magento\CatalogInventory\Model\Indexer\Stock\Action\Full;
1213
use Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\DefaultStock;
@@ -45,6 +46,7 @@ class Stock extends DefaultStock
4546
* @param ActiveTableSwitcher $activeTableSwitcher
4647
* @param StockStatusSelectBuilder $stockStatusSelectBuilder
4748
* @param BundleOptionStockDataSelectBuilder $bundleOptionStockDataSelectBuilder
49+
* @param OptionQtyExpressionProvider $optionQtyExpressionProvider
4850
* @param string $connectionName
4951
*/
5052
public function __construct(
@@ -55,10 +57,14 @@ public function __construct(
5557
ActiveTableSwitcher $activeTableSwitcher,
5658
StockStatusSelectBuilder $stockStatusSelectBuilder,
5759
BundleOptionStockDataSelectBuilder $bundleOptionStockDataSelectBuilder,
60+
private readonly OptionQtyExpressionProvider $optionQtyExpressionProvider,
5861
$connectionName = null
5962
) {
6063
parent::__construct($context, $tableStrategy, $eavConfig, $scopeConfig, $connectionName);
6164

65+
$this->_typeId = Type::TYPE_CODE;
66+
$this->_isComposite = true;
67+
6268
$this->activeTableSwitcher = $activeTableSwitcher;
6369
$this->stockStatusSelectBuilder = $stockStatusSelectBuilder;
6470
$this->bundleOptionStockDataSelectBuilder = $bundleOptionStockDataSelectBuilder;
@@ -198,11 +204,14 @@ protected function _cleanBundleOptionStockData()
198204
private function getOptionsStatusExpression(): \Zend_Db_Expr
199205
{
200206
$connection = $this->getConnection();
207+
208+
$qtyExpr = $this->optionQtyExpressionProvider->getExpression();
201209
$isAvailableExpr = $connection->getCheckSql(
202-
'bs.selection_can_change_qty = 0 AND bs.selection_qty > i.qty',
210+
'bs.selection_can_change_qty = 0 AND bs.selection_qty > ' . $qtyExpr,
203211
'0',
204212
'i.stock_status'
205213
);
214+
206215
if ($this->stockConfiguration->getBackorders()) {
207216
$backordersExpr = $connection->getCheckSql(
208217
'cisi.use_config_backorders = 0 AND cisi.backorders = 0',
@@ -216,6 +225,7 @@ private function getOptionsStatusExpression(): \Zend_Db_Expr
216225
$isAvailableExpr
217226
);
218227
}
228+
219229
if ($this->stockConfiguration->getManageStock()) {
220230
$statusExpr = $connection->getCheckSql(
221231
'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0',

dev/tests/integration/framework/Magento/TestFramework/ApplicationStateComparator/_files/state-skip-list.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@
269269
Magento\TestFramework\ObjectManager\Config::class => null,
270270
Magento\Framework\Escaper::class => null,
271271
Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class => null, // FIXME
272+
\Magento\Framework\DB\Adapter\SqlVersionProvider::class => null,
273+
\Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Table::class => null,
272274
],
273275
'*-fromConstructed' => [
274276
// phpcs:disable Generic.Files.LineLength.TooLong

0 commit comments

Comments
 (0)