Skip to content

Commit bf11e1c

Browse files
Chhandak.BaruaChhandak.Barua
authored andcommitted
ACP2E-59: Importing Bundle with '?' in the option title corrupts how option is displayed and prevents product from being added to cart
1 parent 846a967 commit bf11e1c

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/summary.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
88
$_product = $block->getProduct();
99
?>
10-
<?php if ($_product->isSaleable() && $block->hasOptions()) :?>
10+
<?php if ($_product->isSaleable() && $block->hasOptions()): ?>
1111
<div id="bundleSummary"
1212
class="block-bundle-summary"
1313
data-mage-init='{"sticky":{"container": ".product-add-form"}}'>
@@ -19,11 +19,11 @@ $_product = $block->getProduct();
1919
<?= $block->getImage($_product, 'bundled_product_customization_page')->toHtml() ?>
2020
<div class="product-details">
2121
<strong class="product name"><?= $block->escapeHtml($_product->getName()) ?></strong>
22-
<?php if ($_product->getIsSalable()) :?>
22+
<?php if ($_product->getIsSalable()): ?>
2323
<p class="available stock" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
2424
<span><?= $block->escapeHtml(__('In stock')) ?></span>
2525
</p>
26-
<?php else :?>
26+
<?php else: ?>
2727
<p class="unavailable stock" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
2828
<span><?= $block->escapeHtml(__('Out of stock')) ?></span>
2929
</p>
@@ -58,7 +58,7 @@ $_product = $block->getProduct();
5858
"slideBackSelector": ".action.customization.back",
5959
"bundleProductSelector": "#bundleProduct",
6060
"bundleOptionsContainer": ".product-add-form"
61-
<?php if ($block->isStartCustomization()) :?>
61+
<?php if ($block->isStartCustomization()): ?>
6262
,"autostart": true
6363
<?php endif;?>
6464
}

dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,51 @@ public function testBundleImportUpdateValues(array $expectedValues): void
184184
$this->importedProductSkus = ['Simple 1', 'Simple 2', 'Simple 3', 'Bundle 1'];
185185
}
186186

187+
/**
188+
* Test that Bundle options with question mark are updated correctly by import
189+
*
190+
*
191+
* @magentoAppArea adminhtml
192+
* @magentoDbIsolation enabled
193+
* @magentoAppIsolation enabled
194+
* @return void
195+
*/
196+
public function testBundleImportUpdateValuesWithQuestionMark(): void
197+
{
198+
// import data from CSV file
199+
$pathToFile = __DIR__ . '/../../_files/import_bundle_with_question_mark.csv';
200+
$errors = $this->doImport($pathToFile, Import::BEHAVIOR_APPEND);
201+
$this->assertEquals(0, $errors->getErrorsCount());
202+
203+
// import data from CSV file to update values
204+
$pathToFile2 = __DIR__ . '/../../_files/import_bundle_with_question_mark.csv';
205+
$errors = $this->doImport($pathToFile2, Import::BEHAVIOR_APPEND);
206+
$this->assertEquals(0, $errors->getErrorsCount());
207+
208+
$resource = $this->objectManager->get(ProductResource::class);
209+
$productId = $resource->getIdBySku(self::TEST_PRODUCT_NAME);
210+
$this->assertIsNumeric($productId);
211+
/** @var Product $product */
212+
$product = $this->objectManager->create(Product::class);
213+
$product->load($productId);
214+
215+
$this->assertFalse($product->isObjectNew());
216+
$this->assertEquals(self::TEST_PRODUCT_NAME, $product->getName());
217+
$this->assertEquals(self::TEST_PRODUCT_TYPE, $product->getTypeId());
218+
$this->assertEquals(1, $product->getShipmentType());
219+
220+
$optionIdList = $resource->getProductsIdsBySkus($this->optionSkuList);
221+
$bundleOptionCollection = $product->getExtensionAttributes()->getBundleProductOptions();
222+
$this->assertCount(1, $bundleOptionCollection);
223+
foreach ($bundleOptionCollection as $optionKey => $option) {
224+
$this->assertEquals('checkbox', $option->getData('type'));
225+
$this->assertEquals('Option&#63;', $option->getData('title'));
226+
$this->assertEquals(self::TEST_PRODUCT_NAME, $option->getData('sku'));
227+
228+
}
229+
$this->importedProductSkus = ['Simple 1', 'Bundle 1'];
230+
}
231+
187232
/**
188233
* @magentoDataFixture Magento/Store/_files/second_store.php
189234
* @magentoDbIsolation disabled
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sku,store_view_code,attribute_set_code,product_type,product_websites,name,product_online,price,additional_attributes,qty,out_of_stock_qty,website_id,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values
2+
Simple 1,,Default,simple,base,Simple 1,1,100,,1000,0,1,,,,,
3+
Bundle 1,,Default,bundle,base,Bundle 1,1,,shipment_type=separately,0,0,1,dynamic,dynamic,Price range,dynamic,"name=Option?,type=checkbox,required=1,sku=Simple 1,price=0.0000,default=0,default_qty=1.0000,price_type=fixed,can_change_qty=1"

0 commit comments

Comments
 (0)