Skip to content

Commit e712426

Browse files
committed
Merge remote-tracking branch 'l3/ACP2E-2257' into Tier4-PR-Delivery-12-1-23
2 parents 38c52f1 + 0c1c7e0 commit e712426

File tree

2 files changed

+112
-0
lines changed
  • app/code/Magento/Bundle/Model/ResourceModel/Selection
  • dev/tests/integration/testsuite/Magento/Bundle/Model/ResourceModel/Selection

2 files changed

+112
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ public function getNewEmptyItem()
316316
public function addPriceFilter($product, $searchMin, $useRegularPrice = false)
317317
{
318318
if ($product->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
319+
if (!$this->getStoreId()) {
320+
$this->setStoreId($this->_storeManager->getStore()->getId());
321+
}
319322
$this->addPriceData();
320323
if ($useRegularPrice) {
321324
$minimalPriceExpression = self::INDEX_TABLE_ALIAS . '.price';
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Bundle\Model\ResourceModel\Selection;
20+
21+
use Magento\Catalog\Api\ProductRepositoryInterface;
22+
use Magento\TestFramework\Helper\Bootstrap;
23+
24+
class CollectionTest extends \Magento\Bundle\Model\Product\BundlePriceAbstract
25+
{
26+
/**
27+
* @var CollectionFactory
28+
*/
29+
protected $collectionFactory;
30+
31+
protected function setUp(): void
32+
{
33+
parent::setUp();
34+
35+
$this->collectionFactory = Bootstrap::getObjectManager()->create(CollectionFactory::class);
36+
}
37+
38+
/**
39+
* @magentoIndexerDimensionMode catalog_product_price website
40+
* @magentoDataFixture Magento/Bundle/_files/PriceCalculator/dynamic_bundle_product.php
41+
* @magentoAppIsolation enabled
42+
* @magentoDbIsolation disabled
43+
* @group indexer_dimension
44+
* @dataProvider getTestCases
45+
*/
46+
public function testAddPriceDataWithIndexerDimensionMode(array $strategy, int $expectedCount)
47+
{
48+
$this->prepareFixture($strategy, 'bundle_product');
49+
50+
$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
51+
$product = $productRepository->get('bundle_product', false, null, true);
52+
53+
/** @var Collection $collection */
54+
$collection = $this->collectionFactory->create();
55+
$collection->setStoreId(0);
56+
$collection->addPriceFilter($product, true);
57+
$items = $collection->getItems();
58+
59+
$this->assertCount($expectedCount, $items);
60+
}
61+
62+
public function getTestCases()
63+
{
64+
return [
65+
'Dynamic bundle product with three Simple products' => [
66+
'variation' => $this->getBundleConfiguration(),
67+
'expectedCount' => 1
68+
]
69+
];
70+
}
71+
72+
private function getBundleConfiguration()
73+
{
74+
$optionsData = [
75+
[
76+
'title' => 'op1',
77+
'required' => true,
78+
'type' => 'checkbox',
79+
'links' => [
80+
[
81+
'sku' => 'simple1',
82+
'qty' => 3,
83+
'price' => 100,
84+
'price_type' => 0,
85+
],
86+
[
87+
'sku' => 'simple2',
88+
'qty' => 2,
89+
'price' => 100,
90+
'price_type' => 0,
91+
],
92+
[
93+
'sku' => 'simple3',
94+
'qty' => 1,
95+
'price' => 100,
96+
'price_type' => 0,
97+
],
98+
]
99+
]
100+
];
101+
102+
return [
103+
[
104+
'modifierName' => 'addSimpleProduct',
105+
'data' => [$optionsData]
106+
],
107+
];
108+
}
109+
}

0 commit comments

Comments
 (0)