32 $this->schemaSetup = $schemaSetup;
40 $this->schemaSetup->startSetup();
42 $tableName = $this->schemaSetup->getTable(
'catalog_product_bundle_option_value');
44 $select = $this->schemaSetup->getConnection()->select()
50 'options' => $this->schemaSetup->getTable(
51 'catalog_product_bundle_option' 54 'values.option_id = options.option_id',
55 [
'parent_product_id' =>
'parent_id']
58 $this->schemaSetup->getConnection()->query(
59 $this->schemaSetup->getConnection()->insertFromSelect(
62 [
'value_id',
'parent_product_id'],
63 \
Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE
69 'catalog_product_bundle_selection_price' 71 $tmpTableName = $this->schemaSetup->getTable(
72 'catalog_product_bundle_selection_price_tmp' 75 $existingForeignKeys = $this->schemaSetup->getConnection()->getForeignKeys(
$tableName);
77 foreach ($existingForeignKeys as $key) {
78 $this->schemaSetup->getConnection()->dropForeignKey($key[
'TABLE_NAME'], $key[
'FK_NAME']);
81 $this->schemaSetup->getConnection()->createTable(
82 $this->schemaSetup->getConnection()->createTableByDdl(
$tableName, $tmpTableName)
85 foreach ($existingForeignKeys as $key) {
86 $this->schemaSetup->getConnection()->addForeignKey(
90 $key[
'REF_TABLE_NAME'],
91 $key[
'REF_COLUMN_NAME'],
96 $this->schemaSetup->getConnection()->query(
97 $this->schemaSetup->getConnection()->insertFromSelect(
98 $this->schemaSetup->getConnection()->select()->from(
$tableName),
103 $this->schemaSetup->getConnection()->truncateTable(
$tableName);
105 $columnsToSelect = [];
107 foreach ($this->schemaSetup->getConnection()->describeTable($tmpTableName) as $column) {
108 $alias = $column[
'COLUMN_NAME'] ==
'parent_product_id' ?
'selections.' :
'prices.';
110 $columnsToSelect[] =
$alias . $column[
'COLUMN_NAME'];
113 $select = $this->schemaSetup->getConnection()->select()
115 [
'prices' => $tmpTableName],
119 'selections' => $this->schemaSetup->getTable(
120 'catalog_product_bundle_selection' 123 'prices.selection_id = selections.selection_id',
125 )->columns($columnsToSelect);
127 $this->schemaSetup->getConnection()->query(
131 $this->schemaSetup->getConnection()->dropTable($tmpTableName);
133 $this->schemaSetup->endSetup();