Skip to content

Commit

Permalink
fix upgrade 2.2.X to 3.0.0
Browse files Browse the repository at this point in the history
position are now saved
  • Loading branch information
PrestaSafe committed Mar 29, 2024
1 parent 6eabc44 commit 8ed4e90
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions classes/PrettyBlocksMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,16 @@ public static function migrateLangTable()
Db::getInstance()->execute($sql);
}

$blocks_lang = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'prettyblocks_lang');
$blocks_lang = Db::getInstance()->executeS('SELECT '. _DB_PREFIX_ . 'prettyblocks_lang.* FROM ' . _DB_PREFIX_ . 'prettyblocks_lang INNER JOIN ' . _DB_PREFIX_ . 'prettyblocks ON ' . _DB_PREFIX_ . 'prettyblocks_lang.id_prettyblocks = ' . _DB_PREFIX_ . 'prettyblocks.id_prettyblocks');

foreach ($blocks_lang as $block) {
$existingBlock = new PrettyBlocksModel($block['id_prettyblocks']);
$newBlocks = new PrettyBlocksModel();
$newBlocks->instance_id = $existingBlock->instance_id;
$newBlocks->id_shop = (int) $block['id_shop'];
$newBlocks->id_lang = (int) $block['id_lang'];
$newBlocks->state = $block['state'];
$newBlocks->code = $existingBlock->code;
$newBlocks->zone_name = $existingBlock->zone_name;
$newBlocks->position = $existingBlock->position;

$newBlocks->name = $existingBlock->name;
$newBlocks->config = $existingBlock->config;
$newBlocks->template = $existingBlock->template;
$newBlocks->default_params = $existingBlock->default_params;
$newBlocks->save();

$existingBlock->delete();
Db::getInstance()->update('prettyblocks', array(
'id_shop' => (int) $block['id_shop'],
'id_lang' => (int) $block['id_lang'],
'state' => pSQL($block['state'])
), 'id_prettyblocks = '. $block['id_prettyblocks']);
}

$sql = 'DROP TABLE IF EXISTS ' . _DB_PREFIX_ . 'prettyblocks_lang';
Db::getInstance()->execute($sql);

Expand Down

0 comments on commit 8ed4e90

Please sign in to comment.