From 8ed4e903cd3493a6d766cae242f4f61487480c2f Mon Sep 17 00:00:00 2001 From: Prestasafe Date: Fri, 29 Mar 2024 10:48:06 +0100 Subject: [PATCH] fix upgrade 2.2.X to 3.0.0 position are now saved --- classes/PrettyBlocksMigrate.php | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/classes/PrettyBlocksMigrate.php b/classes/PrettyBlocksMigrate.php index 9f6f2472..c5d02fff 100644 --- a/classes/PrettyBlocksMigrate.php +++ b/classes/PrettyBlocksMigrate.php @@ -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);