Skip to content

Commit

Permalink
fix update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestaSafe committed Aug 8, 2023
1 parent 632bd66 commit 9dfda03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion classes/PrettyBlocksMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ public static function columnExists($tableName, $columnName)
$sql = "SHOW COLUMNS FROM `$tableName` LIKE '$columnName'";
$result = Db::getInstance()->executeS($sql);

return !empty($result);
}

public static function tableExists($tableName)
{
$tableName = _DB_PREFIX_ . $tableName;
$sql = "SHOW TABLES LIKE '$tableName'";
$result = Db::getInstance()->executeS($sql);

// Retourne true si le tableau de résultat n'est pas vide, sinon false.
return !empty($result);
}
Expand All @@ -87,6 +96,9 @@ public static function columnExists($tableName, $columnName)
*/
public static function migrateLangTable()
{
if (!self::tableExists('prettyblocks_lang')) {
return true;
}
if (!self::columnExists('prettyblocks', 'id_shop')
&& !self::columnExists('prettyblocks', 'id_lang')
&& !self::columnExists('prettyblocks', 'state')) {
Expand Down Expand Up @@ -176,7 +188,7 @@ public static function migrateSettings()

$model = $settingModel->getFirst();
if (!$model) {
$model = new PrettyBlocksSettingsModel();
$model = new \PrettyBlocksSettingsModel();
}
$model->theme_name = $theme_name;
$model->settings = json_encode($res, true);
Expand Down
4 changes: 2 additions & 2 deletions classes/PrettyBlocksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public static function updateThemeSettings($stateRequest)
// dump($stateRequest);
// die();
$context = Context::getContext();
$profile = PrettyBlocksSettingsModel::getProfileByTheme($context->shop->theme_name, $context->shop->id);
$profile = \PrettyBlocksSettingsModel::getProfileByTheme($context->shop->theme_name, $context->shop->id);
$res = [];
foreach ($stateRequest as $tabs) {
foreach ($tabs as $name => $field) {
Expand Down Expand Up @@ -807,7 +807,7 @@ public static function getThemeSettings($with_tabs = true, $context = 'front')
{
$theme_settings = \HelperBuilder::hookToArray('ActionRegisterThemeSettings');
$context = Context::getContext();
$settingsDB = PrettyBlocksSettingsModel::getSettings($context->shop->theme_name, $context->shop->id);
$settingsDB = \PrettyBlocksSettingsModel::getSettings($context->shop->theme_name, $context->shop->id);
$res = [];
$no_tabs = [];
foreach ($theme_settings as $key => $settings) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"php-cs-fixer fix --no-interaction --dry-run --diff"
],
"fix": [
"php-cs-fixer fix --dry-run --diff"
"php-cs-fixer fix --diff"
],
"autoindex": [
"vendor/bin/autoindex prestashop:add:index ./"
Expand Down

0 comments on commit 9dfda03

Please sign in to comment.