Skip to content

Commit 16c33ad

Browse files
MAGETWO-70669: Fix fatal errors with deleteOptionsAndSelections #7711
2 parents b66222c + 162d4dd commit 16c33ad

File tree

1 file changed

+9
-5
lines changed
  • app/code/Magento/BundleImportExport/Model/Import/Product/Type

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,13 @@ protected function _initAttributes()
648648
*/
649649
protected function deleteOptionsAndSelections($productIds)
650650
{
651+
if (empty($productIds)) {
652+
return $this;
653+
}
654+
651655
$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
652656
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
657+
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
653658
$valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
654659
['bov' => $optionValueTable],
655660
['value_id']
@@ -662,17 +667,16 @@ protected function deleteOptionsAndSelections($productIds)
662667
$productIds
663668
));
664669
$this->connection->delete(
665-
$optionTable,
670+
$optionValueTable,
666671
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
667672
);
668-
$productIdsInWhere = $this->connection->quoteInto('parent_id IN (?)', $productIds);
669673
$this->connection->delete(
670674
$optionTable,
671-
$this->connection->quoteInto('parent_id IN (?)', $productIdsInWhere)
675+
$this->connection->quoteInto('parent_id IN (?)', $productIds)
672676
);
673677
$this->connection->delete(
674-
$optionTable,
675-
$this->connection->quoteInto('parent_product_id IN (?)', $productIdsInWhere)
678+
$selectionTable,
679+
$this->connection->quoteInto('parent_product_id IN (?)', $productIds)
676680
);
677681
return $this;
678682
}

0 commit comments

Comments
 (0)