[-] Installer : Fix warning during upgrade when issues with shops tables
This commit is contained in:
1 parent
ee9e0b6380
commit
4f0b5307a4
3 files changed
+46
-39
No files matched your search
@@ -41,7 +41,7 @@ function add_default_restrictions_modules_groups()
|
|||||||
FROM `'._DB_PREFIX_.'shop`');
|
FROM `'._DB_PREFIX_.'shop`');
|
||||||
foreach ($groups as $group)
|
foreach ($groups as $group)
|
||||||
{
|
{
|
||||||
if (!is_array($modules))
|
if (!is_array($modules) || !is_array($shops))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -49,10 +49,10 @@ function add_default_restrictions_modules_groups()
|
|||||||
foreach ($modules as $mod)
|
foreach ($modules as $mod)
|
||||||
foreach ($shops as $s)
|
foreach ($shops as $s)
|
||||||
$sql .= '("'.(int)$mod['id_module'].'", "'.(int)$s.'", "'.(int)$group['id_group'].'"),';
|
$sql .= '("'.(int)$mod['id_module'].'", "'.(int)$s.'", "'.(int)$group['id_group'].'"),';
|
||||||
// removing last comma to avoid SQL error
|
// removing last comma to avoid SQL error
|
||||||
$sql = substr($sql, 0, strlen($sql) - 1);
|
$sql = substr($sql, 0, strlen($sql) - 1);
|
||||||
$res &= Db::getInstance()->execute($sql);
|
$res &= Db::getInstance()->execute($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -54,29 +54,35 @@ function generate_root_category_for_multishop()
|
|||||||
');
|
');
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($langs as $lang)
|
if(is_array($shops) && is_array($langs))
|
||||||
foreach ($shops as $shop)
|
{
|
||||||
$data[] = array(
|
foreach ($langs as $lang)
|
||||||
'id_lang' => $lang['id_lang'],
|
foreach ($shops as $shop)
|
||||||
'id_shop' => $shop['id_shop'],
|
$data[] = array(
|
||||||
'id_category' => $id,
|
'id_lang' => $lang['id_lang'],
|
||||||
'name' => 'Root',
|
'id_shop' => $shop['id_shop'],
|
||||||
'link_rewrite' => '',
|
'id_category' => $id,
|
||||||
);
|
'name' => 'Root',
|
||||||
Db::getInstance()->insert('category_lang', $data);
|
'link_rewrite' => '',
|
||||||
|
);
|
||||||
|
Db::getInstance()->insert('category_lang', $data);
|
||||||
|
}
|
||||||
|
|
||||||
$categories = Db::getInstance()->executeS('
|
$categories = Db::getInstance()->executeS('
|
||||||
SELECT `id_category`
|
SELECT `id_category`
|
||||||
FROM `'._DB_PREFIX_.'category`
|
FROM `'._DB_PREFIX_.'category`
|
||||||
');
|
');
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($categories as $category)
|
if(is_array($shops) && is_array($categories))
|
||||||
foreach ($shops as $shop)
|
{
|
||||||
$data[] = array(
|
foreach ($categories as $category)
|
||||||
'id_category' => $category['id_category'],
|
foreach ($shops as $shop)
|
||||||
'id_shop' => $shop['id_shop']
|
$data[] = array(
|
||||||
);
|
'id_category' => $category['id_category'],
|
||||||
Db::getInstance()->insert('category_shop', $data);
|
'id_shop' => $shop['id_shop']
|
||||||
|
);
|
||||||
|
Db::getInstance()->insert('category_shop', $data);
|
||||||
|
}
|
||||||
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'category`
|
UPDATE `'._DB_PREFIX_.'category`
|
||||||
@@ -90,4 +96,4 @@ function generate_root_category_for_multishop()
|
|||||||
');
|
');
|
||||||
|
|
||||||
generate_ntree();
|
generate_ntree();
|
||||||
}
|
}
|
||||||
@@ -160,22 +160,24 @@ function p15012_add_missing_columns()
|
|||||||
if (empty($table))
|
if (empty($table))
|
||||||
continue;
|
continue;
|
||||||
$list_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.$table.'`');
|
$list_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.$table.'`');
|
||||||
foreach($list_fields as $k => $field)
|
if (is_array($list_fields))
|
||||||
$list_fields[$k] = $field['Field'];
|
foreach($list_fields as $k => $field)
|
||||||
foreach ($cols as $col => $q)
|
$list_fields[$k] = $field['Field'];
|
||||||
{
|
if (is_array($cols))
|
||||||
// do only if column exists
|
foreach ($cols as $col => $q)
|
||||||
if (in_array($col, $list_fields))
|
|
||||||
$do = 'mod';
|
|
||||||
else
|
|
||||||
$do = 'add';
|
|
||||||
|
|
||||||
if (!empty($q[$do]))
|
|
||||||
{
|
{
|
||||||
if (!$db->execute($q[$do]))
|
// do only if column exists
|
||||||
$errors[] = '<subquery><query>'.$q[$do].'</query><error>'.$db->getMsgError().'</error></subquery>';
|
if (is_array($list_fields) && in_array($col, $list_fields))
|
||||||
|
$do = 'mod';
|
||||||
|
else
|
||||||
|
$do = 'add';
|
||||||
|
|
||||||
|
if (!empty($q[$do]))
|
||||||
|
{
|
||||||
|
if (!$db->execute($q[$do]))
|
||||||
|
$errors[] = '<subquery><query>'.$q[$do].'</query><error>'.$db->getMsgError().'</error></subquery>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($errors) > 0)
|
if (sizeof($errors) > 0)
|
||||||
@@ -185,5 +187,4 @@ function p15012_add_missing_columns()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user