Skip to content

Commit 91d137c

Browse files
committed
MAGETWO-90286: Bundle Product is_salable check is wrong
1 parent db09833 commit 91d137c

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ public function addQuantityFilter()
184184
)
185185
->where(
186186
'('
187-
. 'selection.selection_can_change_qty'
187+
. 'selection.selection_can_change_qty > 0'
188188
. ' or '
189189
. 'selection.selection_qty <= stock.qty'
190190
. ' or '
191191
.'stock_item.manage_stock = 0'
192-
. ') and stock.stock_status = 1'
193-
);
192+
. ')'
193+
)
194+
->where('stock.stock_status = 1');
195+
194196
return $this;
195197
}
196198

app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ public function testAddQuantityFilter()
115115
$itemTableName = 'cataloginventory_stock_item';
116116
$this->entity->expects($this->exactly(2))
117117
->method('getTable')
118-
->willReturnOnConsecutiveCalls($itemTableName, $statusTableName);
118+
->willReturnMap([
119+
['cataloginventory_stock_item', $itemTableName],
120+
['cataloginventory_stock_status', $statusTableName],
121+
]);
119122
$this->select->expects($this->exactly(2))
120123
->method('joinInner')
121124
->withConsecutive(
@@ -131,18 +134,22 @@ public function testAddQuantityFilter()
131134
]
132135
)->willReturnSelf();
133136
$this->select
134-
->expects($this->once())
137+
->expects($this->exactly(2))
135138
->method('where')
136-
->with(
137-
'('
138-
. 'selection.selection_can_change_qty'
139-
. ' or '
140-
. 'selection.selection_qty <= stock.qty'
141-
. ' or '
142-
.'stock_item.manage_stock = 0'
143-
. ') and stock.stock_status = 1'
144-
)
145-
->willReturnSelf();
139+
->withConsecutive(
140+
[
141+
'('
142+
. 'selection.selection_can_change_qty > 0'
143+
. ' or '
144+
. 'selection.selection_qty <= stock.qty'
145+
. ' or '
146+
.'stock_item.manage_stock = 0'
147+
. ')',
148+
],
149+
[
150+
'stock.stock_status = 1',
151+
]
152+
)->willReturnSelf();
146153

147154
$this->assertEquals($this->model, $this->model->addQuantityFilter());
148155
}

0 commit comments

Comments
 (0)