Skip to content

Commit d4648e4

Browse files
committed
Merge branch 'ACP2E-3092' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-2024-07-11
2 parents d93e234 + ab2bb4d commit d4648e4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ public function getAddToCartPostParams(Product $product)
310310
'action' => $url,
311311
'data' => [
312312
'product' => $product->getEntityId(),
313+
'options' => $this->optionsData->getOptionsData($product),
313314
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($url),
314315
]
315316
];

dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66

77
namespace Magento\CatalogWidget\Block\Product;
88

9+
use Magento\Bundle\Test\Fixture\Option as BundleOptionFixture;
10+
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
11+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
912
use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
1013
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
1114
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
1215
use Magento\Framework\ObjectManagerInterface;
16+
use Magento\TestFramework\Fixture\DataFixture;
17+
use Magento\TestFramework\Fixture\DataFixtureStorage;
18+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
19+
use Magento\TestFramework\Fixture\DbIsolation;
1320
use Magento\TestFramework\Helper\Bootstrap;
1421
use PHPUnit\Framework\TestCase;
1522

@@ -34,11 +41,17 @@ class ProductListTest extends TestCase
3441
*/
3542
protected $objectManager;
3643

44+
/**
45+
* @var DataFixtureStorage
46+
*/
47+
private $fixtures;
48+
3749
protected function setUp(): void
3850
{
3951
$this->objectManager = Bootstrap::getObjectManager();
4052
$this->block = $this->objectManager->create(ProductsList::class);
4153
$this->categoryCollection = $this->objectManager->create(CategoryCollection::class);
54+
$this->fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
4255
}
4356

4457
/**
@@ -257,6 +270,29 @@ public function testCreateAnchorCollection()
257270
);
258271
}
259272

273+
#[
274+
DbIsolation(false),
275+
DataFixture(ProductFixture::class, ['price' => 10], 'p1'),
276+
DataFixture(ProductFixture::class, ['price' => 20], 'p2'),
277+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p1$', '$p2$']], 'opt1'),
278+
DataFixture(BundleProductFixture::class, ['_options' => ['$opt1$']], 'bundle1'),
279+
]
280+
public function testBundleProductList()
281+
{
282+
$postParams = $this->block->getAddToCartPostParams($this->fixtures->get('bundle1'));
283+
284+
$this->assertArrayHasKey(
285+
'product',
286+
$postParams['data'],
287+
'Bundle product options is missing from POST params.'
288+
);
289+
$this->assertArrayHasKey(
290+
'options',
291+
$postParams['data'],
292+
'Bundle product options is missing from POST params.'
293+
);
294+
}
295+
260296
/**
261297
* Test that price rule condition works correctly
262298
*

0 commit comments

Comments
 (0)