Skip to content

Commit 14768a8

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 9e6eec8 commit 14768a8

File tree

2 files changed

+22
-18
lines changed
  • app/code/Magento
    • BundleImportExport/Model/Import/Product/Type
    • Bundle/view/frontend/templates/catalog/product/view

2 files changed

+22
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $_product = $block->getProduct();
3737
<ul data-mage-init='{"productSummary": []}' class="bundle items"></ul>
3838
<script data-template="bundle-summary" type="text/x-magento-template">
3939
<li>
40-
<strong class="label v"><%= data._label_ %>:</strong>
40+
<strong class="label v"><%- data._label_ %>:</strong>
4141
<div data-container="options"></div>
4242
</li>
4343
</script>

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ protected function parseSelections($rowData, $entityId)
183183
);
184184
$selections = explode(
185185
Product::PSEUDO_MULTI_LINE_SEPARATOR,
186-
str_replace('?', '&#63;', $rowData['bundle_values'])
186+
$rowData['bundle_values']
187+
//str_replace('?', '&#63;', $rowData['bundle_values'])
187188
);
188189
foreach ($selections as $selection) {
189190
$values = explode($this->_entityModel->getMultipleValueSeparator(), $selection);
@@ -199,11 +200,7 @@ protected function parseSelections($rowData, $entityId)
199200
$this->_cachedOptions[$entityId][$option['name']]['selections'] = [];
200201
}
201202
$this->_cachedOptions[$entityId][$option['name']]['selections'][] = $option;
202-
$this->_cachedOptionSelectQuery[] =
203-
$this->connection->quoteInto(
204-
'(parent_id = ' . (int)$entityId . ' AND title = ?)',
205-
$option['name']
206-
);
203+
$this->_cachedOptionSelectQuery[] = 'parent_id =' . (int)$entityId . ' AND title =' . $option['name'];
207204
}
208205
}
209206
return $selections;
@@ -474,18 +471,25 @@ protected function transformBundleCustomAttributes($rowData)
474471
*/
475472
protected function populateExistingOptions()
476473
{
477-
$existingOptions = $this->connection->fetchAssoc(
478-
$this->connection->select()->from(
479-
['bo' => $this->_resource->getTableName('catalog_product_bundle_option')],
480-
['option_id', 'parent_id', 'required', 'position', 'type']
481-
)->joinLeft(
482-
['bov' => $this->_resource->getTableName('catalog_product_bundle_option_value')],
483-
'bo.option_id = bov.option_id',
484-
['value_id', 'title']
485-
)->where(
486-
implode(' OR ', $this->_cachedOptionSelectQuery)
487-
)
474+
$select = $this->connection->select()->from(
475+
['bo' => $this->_resource->getTableName('catalog_product_bundle_option')],
476+
['option_id', 'parent_id', 'required', 'position', 'type']
477+
)->joinLeft(
478+
['bov' => $this->_resource->getTableName('catalog_product_bundle_option_value')],
479+
'bo.option_id = bov.option_id',
480+
['value_id', 'title']
488481
);
482+
$orWhere = false;
483+
foreach ($this->_cachedOptionSelectQuery as $item) {
484+
$expItem = explode('=',$item);
485+
if ($orWhere) {
486+
$select->orWhere($expItem[0].' = '.$expItem[1].' = ?', $expItem[2]);
487+
} else {
488+
$select->where($expItem[0].' = '.$expItem[1].' = ?', $expItem[2]);
489+
$orWhere = true;
490+
}
491+
}
492+
$existingOptions = $this->connection->fetchAssoc($select);
489493
foreach ($existingOptions as $optionId => $option) {
490494
$this->_cachedOptions[$option['parent_id']][$option['title']]['option_id'] = $optionId;
491495
foreach ($option as $key => $value) {

0 commit comments

Comments
 (0)