Skip to content

Commit 68a8b56

Browse files
committed
Merge remote-tracking branch 'local/ACP2E-1388' into PR_7_JAN_2023
2 parents a763c9c + 61df700 commit 68a8b56

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPric
8484
[(int)$option->getOptionId()],
8585
$bundleProduct
8686
);
87+
$selectionsCollection->setFlag('has_stock_status_filter', true);
8788
$selectionsCollection->removeAttributeToSelect();
88-
$selectionsCollection->addQuantityFilter();
8989

9090
if (!$useRegularPrice) {
9191
$selectionsCollection->addAttributeToSelect('special_price');
@@ -140,6 +140,9 @@ private function isShouldFindMinOption(Product $bundleProduct, $searchMin)
140140
private function addMiniMaxPriceList(Product $bundleProduct, $selectionsCollection, $searchMin, $useRegularPrice)
141141
{
142142
$selectionsCollection->addPriceFilter($bundleProduct, $searchMin, $useRegularPrice);
143+
if ($bundleProduct->isSalable()) {
144+
$selectionsCollection->addQuantityFilter();
145+
}
143146
$selectionsCollection->setPage(0, 1);
144147

145148
$selection = $selectionsCollection->getFirstItem();

app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/DefaultSelectionPriceListProviderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,47 @@ public function testGetPriceList(): void
177177
$this->selectionCollection->expects($this->once())
178178
->method('getIterator')
179179
->willReturn(new \ArrayIterator([]));
180+
$this->selectionCollection->expects($this->once())
181+
->method('setFlag')
182+
->with('has_stock_status_filter', true);
180183

181184
$this->model->getPriceList($this->product, false, false);
182185
}
186+
187+
public function testGetPriceListWithSearchMin(): void
188+
{
189+
$option = $this->createMock(Option::class);
190+
$option->expects($this->once())->method('getRequired')
191+
->willReturn(true);
192+
$this->optionsCollection->expects($this->any())
193+
->method('getIterator')
194+
->willReturn(new \ArrayIterator([$option]));
195+
$this->typeInstance->expects($this->any())
196+
->method('getOptionsCollection')
197+
->with($this->product)
198+
->willReturn($this->optionsCollection);
199+
$this->product->expects($this->any())
200+
->method('getTypeInstance')
201+
->willReturn($this->typeInstance);
202+
$this->selectionCollection->expects($this->once())
203+
->method('getFirstItem')
204+
->willReturn($this->createMock(Product::class));
205+
$this->typeInstance->expects($this->once())
206+
->method('getSelectionsCollection')
207+
->willReturn($this->selectionCollection);
208+
$this->selectionCollection->expects($this->once())
209+
->method('setFlag')
210+
->with('has_stock_status_filter', true);
211+
$this->selectionCollection->expects($this->once())
212+
->method('addQuantityFilter');
213+
$this->product->expects($this->once())->method('isSalable')->willReturn(true);
214+
$this->optionsCollection->expects($this->once())
215+
->method('getSize')
216+
->willReturn(1);
217+
$this->optionsCollection->expects($this->once())
218+
->method('addFilter')
219+
->willReturn($this->optionsCollection);
220+
221+
$this->model->getPriceList($this->product, true, false);
222+
}
183223
}

0 commit comments

Comments
 (0)