// normalization / minor fix in php upgrader files
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 7373 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -35,12 +35,12 @@ function add_missing_rewrite_value()
|
||||
AND m.`page` != "index"
|
||||
');
|
||||
if (sizeof($pages) && is_array($pages))
|
||||
foreach ($pages as $page)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'meta_lang`
|
||||
SET `url_rewrite` = "'.pSQL(Tools::str2url($page['title'])).'"
|
||||
WHERE `id_meta` = '.(int)$page['id_meta'].'
|
||||
AND `id_lang` = '.(int)$page['id_lang']);
|
||||
}
|
||||
foreach ($pages as $page)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'meta_lang`
|
||||
SET `url_rewrite` = "'.pSQL(Tools::str2url($page['title'])).'"
|
||||
WHERE `id_meta` = '.(int)$page['id_meta'].'
|
||||
AND `id_lang` = '.(int)$page['id_lang']);
|
||||
}
|
||||
}
|
||||
@@ -20,29 +20,29 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 12447 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function add_module_to_hook($module_name, $hook_name)
|
||||
{
|
||||
$result = false;
|
||||
$res = true;
|
||||
|
||||
$id_module = Db::getInstance()->getValue('
|
||||
SELECT `id_module` FROM `'._DB_PREFIX_.'module`
|
||||
WHERE `name` = \''.pSQL($module_name).'\''
|
||||
WHERE `name` = "'.$module_name.'"'
|
||||
);
|
||||
|
||||
if ((int)$id_module > 0)
|
||||
{
|
||||
$id_hook = Db::getInstance()->getValue('
|
||||
SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = \''.pSQL($hook_name).'\'
|
||||
SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'"
|
||||
');
|
||||
|
||||
if ((int)$id_hook > 0)
|
||||
{
|
||||
$result = Db::getInstance()->execute('
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT IGNORE INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_hook`, `position`)
|
||||
VALUES (
|
||||
'.(int)$id_module.',
|
||||
@@ -53,6 +53,6 @@ function add_module_to_hook($module_name, $hook_name)
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7450 $
|
||||
* @version Release: $Revision: 12447 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
function add_order_state($conf_name, $name, $invoice, $send_email, $color, $unremovable, $logable, $delivery, $template = null)
|
||||
{
|
||||
$res = true;
|
||||
$name_lang = array();
|
||||
$template_lang = array();
|
||||
foreach (explode('|', $name) AS $item)
|
||||
@@ -42,22 +43,29 @@ function add_order_state($conf_name, $name, $invoice, $send_email, $color, $unre
|
||||
$template_lang[$temp[0]] = $temp[1];
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_state` (`invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`)
|
||||
VALUES ('.(int)$invoice.', '.(int)$send_email.', \''.pSQL($color).'\', '.(int)$unremovable.', '.(int)$logable.', '.(int)$delivery.')');
|
||||
VALUES ('.(int)$invoice.', '.(int)$send_email.', "'.$color.'", '.(int)$unremovable.', '.(int)$logable.', '.(int)$delivery.')');
|
||||
|
||||
$id_order_state = Db::getInstance()->getValue('
|
||||
SELECT MAX(`id_order_state`)
|
||||
FROM `'._DB_PREFIX_.'order_state`
|
||||
');
|
||||
FROM `'._DB_PREFIX_.'order_state`');
|
||||
|
||||
foreach (Language::getLanguages() AS $lang)
|
||||
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
|
||||
foreach ($languages AS $lang)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
$iso_code = $lang['iso_code'];
|
||||
$iso_code_name = isset($name_lang[$iso_code])?$iso_code:'en';
|
||||
$iso_code_template = isset($template_lang[$iso_code])?$iso_code:'en';
|
||||
$name = isset($name_lang[$iso_code]) ? $name_lang[$iso_code] : $name_lang['en'];
|
||||
$template = isset($template_lang[$iso_code]) ? $template_lang[$iso_code] : '';
|
||||
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT IGNORE INTO `'._DB_PREFIX_.'order_state_lang` (`id_lang`, `id_order_state`, `name`, `template`)
|
||||
VALUES ('.(int)$lang['id_lang'].', '.(int)$id_order_state.', \''.pSQL(isset($name_lang[$lang['iso_code']]) ? $name_lang[$lang['iso_code']] : $name_lang['en']).'\', \''.pSQL(isset($template_lang[$lang['iso_code']]) ? $template_lang[$lang['iso_code']] : (isset($template_lang['en']) ? $template_lang['en'] : '')).'\')
|
||||
VALUES ('.(int)$lang['id_lang'].', '.(int)$id_order_state.', "'. $name .'", "'. $template .'")
|
||||
');
|
||||
}
|
||||
|
||||
Configuration::updateValue($conf_name, $id_order_state);
|
||||
}
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("'.$conf_name.'", "'.$id_order_state.'"');
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -29,14 +29,14 @@ define('_CONTAINS_REQUIRED_FIELD_', 2);
|
||||
|
||||
function add_required_customization_field_flag()
|
||||
{
|
||||
if (($result = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'customization_field` WHERE `required` = 1')) === false)
|
||||
if (($result = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `'._DB_PREFIX_.'customization_field` WHERE `required` = 1')) === false)
|
||||
return false;
|
||||
if (Db::getInstance()->numRows())
|
||||
{
|
||||
$productIds = array();
|
||||
foreach ($result AS $row)
|
||||
$productIds[] = (int)($row['id_product']);
|
||||
if (!Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `customizable` = '._CONTAINS_REQUIRED_FIELD_.' WHERE `id_product` IN ('.implode(', ', $productIds).')'))
|
||||
if (!Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `customizable` = '._CONTAINS_REQUIRED_FIELD_.' WHERE `id_product` IN ('.implode(', ', $productIds).')'))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -27,9 +27,10 @@
|
||||
|
||||
function alter_productcomments_guest_index()
|
||||
{
|
||||
Configuration::loadConfiguration();
|
||||
$productcomments = Module::getInstanceByName('productcomments');
|
||||
if (!$productcomments->id)
|
||||
$id_productcomments = Db::getInstance()->getValue('SELECT id_module
|
||||
FROM `'._DB_PREFIX_.'module` WHERE name = "productcomments"');
|
||||
|
||||
if (!$id_productcomments)
|
||||
return;
|
||||
|
||||
DB::getInstance()->Execute('
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function attribute_group_clean_combinations()
|
||||
{
|
||||
$attributeCombinations = Db::getInstance()->ExecuteS('SELECT
|
||||
pac.`id_attribute`, pa.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)');
|
||||
$toRemove = array();
|
||||
foreach ($attributeCombinations AS $attributeCombination)
|
||||
if ((int)($attributeCombination['id_attribute']) == 0)
|
||||
$toRemove[] = (int)($attributeCombination['id_product_attribute']);
|
||||
|
||||
if (!empty($toRemove))
|
||||
{
|
||||
$res = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product_attribute` IN ('.implode(', ', $toRemove).')');
|
||||
return $res;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 6594 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
+2
-2
@@ -20,14 +20,14 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function configuration_double_cleaner()
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT name, MIN(id_configuration) AS minid
|
||||
FROM '._DB_PREFIX_.'configuration
|
||||
GROUP BY name
|
||||
+5
-3
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -32,8 +32,10 @@ function convert_product_price()
|
||||
$taxRates = array();
|
||||
foreach ($taxes as $data)
|
||||
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100;
|
||||
$results = DB::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax` FROM `'._DB_PREFIX_.'product`');
|
||||
foreach ($results as $row)
|
||||
$resource = DB::getInstance()->ExecuteS('SELECT `id_product`, `price`, `id_tax` FROM `'._DB_PREFIX_.'product`', false);
|
||||
if (!$resource)
|
||||
die(mysql_error());
|
||||
while ($row = DB::getInstance()->nextRow($resource))
|
||||
if ($row['id_tax'])
|
||||
{
|
||||
$price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
|
||||
@@ -28,9 +28,19 @@
|
||||
function deactivate_custom_modules()
|
||||
{
|
||||
$db = Db::getInstance();
|
||||
$modulesDirOnDisk = Module::getModulesDirOnDisk();
|
||||
$modulesDirOnDisk = array();
|
||||
$modules = scandir(_PS_MODULE_DIR_);
|
||||
foreach ($modules AS $name)
|
||||
{
|
||||
if (is_dir(_PS_MODULE_DIR_.$name) && Tools::file_exists_cache(_PS_MODULE_DIR_.$name.'/'.$name.'.php'))
|
||||
{
|
||||
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $name))
|
||||
die(Tools::displayError().' (Module '.$name.')');
|
||||
$modulesDirOnDisk[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'modules_list.xml';
|
||||
$module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'modules_list.xml';
|
||||
$nativeModules = simplexml_load_file($module_list_xml);
|
||||
$nativeModules = $nativeModules->modules;
|
||||
foreach ($nativeModules as $nativeModulesType)
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ function delivery_number_set()
|
||||
$number = 1;
|
||||
|
||||
// Update each order with a number
|
||||
$result = Db::getInstance()->executeS('
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
ORDER BY id_order');
|
||||
@@ -44,7 +44,7 @@ function delivery_number_set()
|
||||
$oS = new OrderState((int)($row2['id_order_state']), Configuration::get('PS_LANG_DEFAULT'));
|
||||
if ($oS->delivery)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET delivery_number = '.(int)($number++).', `delivery_date` = `date_add` WHERE id_order = '.(int)($order->id));
|
||||
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'orders SET delivery_number = '.(int)($number++).', `delivery_date` = `date_add` WHERE id_order = '.(int)($order->id));
|
||||
break ;
|
||||
}
|
||||
}
|
||||
Executable → Regular
+5
-12
@@ -20,21 +20,14 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function setAllGroupsOnHomeCategory()
|
||||
function ecotax_tax_application_fix()
|
||||
{
|
||||
$results = Group::getGroups(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$groups = array();
|
||||
foreach ($results AS $result)
|
||||
$groups[] = $result['id_group'];
|
||||
if (is_array($groups) && sizeof($groups))
|
||||
{
|
||||
$category = new Category(1);
|
||||
$category->cleanGroups();
|
||||
$category->addGroups($groups);
|
||||
}
|
||||
if (!Db::getInstance()->execute('SELECT `ecotax_tax_rate` FROM `'._DB_PREFIX_.'order_detail` LIMIT 1'))
|
||||
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `ecotax_tax_rate` DECIMAL(5, 3) NOT NULL AFTER `ecotax`');
|
||||
return true;
|
||||
}
|
||||
@@ -27,5 +27,23 @@
|
||||
|
||||
function generate_ntree()
|
||||
{
|
||||
Category::regenerateEntireNtree();
|
||||
$categories = Db::getInstance()->ExecuteS('SELECT id_category, id_parent FROM '._DB_PREFIX_.'category ORDER BY id_parent ASC, position ASC');
|
||||
$categoriesArray = array();
|
||||
foreach ($categories AS $category)
|
||||
$categoriesArray[(int)$category['id_parent']]['subcategories'][(int)$category['id_category']] = 1;
|
||||
$n = 1;
|
||||
generate_ntree_subTree($categoriesArray, 1, $n);
|
||||
}
|
||||
|
||||
function generate_ntree_subTree(&$categories, $id_category, &$n)
|
||||
{
|
||||
$left = (int)$n++;
|
||||
if (isset($categories[(int)$id_category]['subcategories']))
|
||||
foreach (array_keys($categories[(int)$id_category]['subcategories']) AS $id_subcategory)
|
||||
generate_ntree_subTree($categories, (int)$id_subcategory, $n);
|
||||
$right = (int)$n++;
|
||||
|
||||
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'category
|
||||
SET nleft = '.(int)$left.', nright = '.(int)$right.'
|
||||
WHERE id_category = '.(int)$id_category.' LIMIT 1');
|
||||
}
|
||||
|
||||
@@ -1,87 +1,117 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function generate_tax_rules()
|
||||
{
|
||||
$taxes = Tax::getTaxes(Configuration::get('PS_LANG_DEFAULT'), true);
|
||||
$countries = Country::getCountries(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$ps_lang_default = Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_LANG_DEFAULT"');
|
||||
$taxes = Db::getInstance('SELECT * from `'._DB_PREFIX_.'tax` WHERE active = 1');
|
||||
|
||||
foreach ($taxes AS $tax)
|
||||
{
|
||||
$insert = '';
|
||||
$id_tax = $tax['id_tax'];
|
||||
|
||||
$group = new TaxRulesGroup();
|
||||
$group->active = 1;
|
||||
$group->name = 'Rule '.$tax['rate'].'%';
|
||||
$group->save();
|
||||
$id_tax_rules_group = $group->id;
|
||||
foreach ($taxes AS $tax)
|
||||
{
|
||||
$insert = '';
|
||||
$id_tax = $tax['id_tax'];
|
||||
$row = array(
|
||||
'active' => 1,
|
||||
'id_tax' => $id_tax,
|
||||
'name' => 'Rule '.$tax['rate'].'%',
|
||||
);
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'category_group', $row, 'INSERT');
|
||||
$id_tax_rules_group = Db::getInstance()->insert_id;
|
||||
|
||||
|
||||
$countries = Db::getInstance()->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'country` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (c.`id_zone` = z.`id_zone`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_zone` tz ON (tz.`id_zone` = z.`id_zone`)
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
if ($countries)
|
||||
{
|
||||
foreach ($countries AS $country)
|
||||
{
|
||||
$res = Db::getInstance()->execute('
|
||||
$countries = Db::getInstance()->ExecuteS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'country` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (c.`id_zone` = z.`id_zone`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_zone` tz ON (tz.`id_zone` = z.`id_zone`)
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
if ($countries)
|
||||
{
|
||||
foreach ($countries AS $country)
|
||||
{
|
||||
$res = Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES (
|
||||
'.(int)$group->id.',
|
||||
'.(int)$id_tax_rules_group.',
|
||||
'.(int)$country['id_country'].',
|
||||
0,
|
||||
0,
|
||||
'.(int)$id_tax.
|
||||
')');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$states = Db::getInstance()->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'states s
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_state ts ON (ts.`id_state` = s.`id_state`)
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
$states = Db::getInstance()->ExecuteS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'states s
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_state ts ON (ts.`id_state` = s.`id_state`)
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
|
||||
if ($states)
|
||||
{
|
||||
foreach ($states AS $state)
|
||||
{
|
||||
if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX)))
|
||||
$tax_behavior = PS_PRODUCT_TAX;
|
||||
else
|
||||
$tax_behavior = $state['tax_behavior'];
|
||||
if ($states)
|
||||
{
|
||||
foreach ($states AS $state)
|
||||
{
|
||||
if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX)))
|
||||
$tax_behavior = PS_PRODUCT_TAX;
|
||||
else
|
||||
$tax_behavior = $state['tax_behavior'];
|
||||
|
||||
$res = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES (
|
||||
'.(int)$group->id.',
|
||||
'.(int)$id_tax_rules_group.',
|
||||
'.(int)$state['id_country'].',
|
||||
'.(int)$state['id_state'].',
|
||||
'.(int)$tax_behavior.',
|
||||
'.(int)$id_tax.
|
||||
')');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'product`
|
||||
SET `id_tax_rules_group` = '.(int)$group->id.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'product`
|
||||
SET `id_tax_rules_group` = '.(int)$id_tax_rules_group.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'carrier`
|
||||
SET `id_tax_rules_group` = '.(int)$group->id.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'carrier`
|
||||
SET `id_tax_rules_group` = '.(int)$id_tax_rules_group.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
|
||||
|
||||
if (Configuration::get('SOCOLISSIMO_OVERCOST_TAX') == $id_tax)
|
||||
Configuration::updateValue('SOCOLISSIMO_OVERCOST_TAX', $group->id);
|
||||
}
|
||||
$socolissimo_overcost_tax = Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
|
||||
if ($socolissimo_overcost_tax == $id_tax)
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("PS_POUET", "'.$id_tax_rules_group.'"');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 8238 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -42,6 +42,6 @@ function gridextjs_deprecated()
|
||||
if (file_exists($gridextjs_path))
|
||||
return rename($gridextjs_path, str_replace('gridextjs', 'gridextjs.deprecated', $gridextjs_path));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-15
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -31,17 +31,3 @@ function group_reduction_column_fix()
|
||||
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `group_reduction` DECIMAL(10, 2) NOT NULL AFTER `reduction_amount`');
|
||||
return true;
|
||||
}
|
||||
|
||||
function ecotax_tax_application_fix()
|
||||
{
|
||||
if (!Db::getInstance()->execute('SELECT `ecotax_tax_rate` FROM `'._DB_PREFIX_.'order_detail` LIMIT 1'))
|
||||
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `ecotax_tax_rate` DECIMAL(5, 3) NOT NULL AFTER `ecotax`');
|
||||
return true;
|
||||
}
|
||||
|
||||
function id_currency_country_fix()
|
||||
{
|
||||
if (!Db::getInstance()->execute('SELECT `id_currency` FROM `'._DB_PREFIX_.'country` LIMIT 1'))
|
||||
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'country` ADD `id_currency` INT NOT NULL DEFAULT \'0\' AFTER `id_zone`');
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function id_currency_country_fix()
|
||||
{
|
||||
if (!Db::getInstance()->execute('SELECT `id_currency` FROM `'._DB_PREFIX_.'country` LIMIT 1'))
|
||||
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'country` ADD `id_currency` INT NOT NULL DEFAULT \'0\' AFTER `id_zone`');
|
||||
return true;
|
||||
}
|
||||
+3
-3
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ function invoice_number_set()
|
||||
$number = 1;
|
||||
|
||||
// Update each order with a number
|
||||
$result = Db::getInstance()->executeS('
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
ORDER BY id_order');
|
||||
@@ -44,7 +44,7 @@ function invoice_number_set()
|
||||
$oS = new OrderState((int)($row2['id_order_state']), Configuration::get('PS_LANG_DEFAULT'));
|
||||
if ($oS->invoice)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET invoice_number = '.(int)($number++).', `invoice_date` = `date_add` WHERE id_order = '.(int)($order->id));
|
||||
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'orders SET invoice_number = '.(int)($number++).', `invoice_date` = `date_add` WHERE id_order = '.(int)($order->id));
|
||||
break ;
|
||||
}
|
||||
}
|
||||
+10
-8
@@ -20,13 +20,15 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
if(!defined('_PS_MAGIC_QUOTES_GPC_'))
|
||||
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
|
||||
if (!defined('_PS_MAGIC_QUOTES_GPC_'))
|
||||
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
|
||||
if (!defined('_PS_MYSQL_REAL_ESCAPE_STRING_'))
|
||||
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));
|
||||
|
||||
function latin1_database_to_utf8()
|
||||
{
|
||||
@@ -70,7 +72,7 @@ function latin1_database_to_utf8()
|
||||
array('name' => 'order_state_lang', 'id' => 'id_order_state', 'lang' => true, 'fields' => array('name', 'template')),
|
||||
array('name' => 'product', 'id' => 'id_product', 'fields' => array('ean13', 'reference')),
|
||||
array('name' => 'product_attribute', 'id' => 'id_product_attribute', 'fields' => array('reference', 'ean13')),
|
||||
array('name' => 'product_download', 'id' => 'id_product_download', 'fields' => array('display_filename', 'filename')),
|
||||
array('name' => 'product_download', 'id' => 'id_product_download', 'fields' => array('display_filename', 'physically_filename')),
|
||||
array('name' => 'product_lang', 'id' => 'id_product', 'lang' => true, 'fields' => array('description', 'description_short', 'link_rewrite', 'meta_description', 'meta_keywords', 'meta_title', 'name', 'availability')),
|
||||
array('name' => 'profile_lang', 'id' => 'id_profile', 'lang' => true, 'fields' => array('name')),
|
||||
array('name' => 'quick_access', 'id' => 'id_quick_access', 'fields' => array('link')),
|
||||
@@ -86,7 +88,7 @@ function latin1_database_to_utf8()
|
||||
foreach ($tables AS $table)
|
||||
{
|
||||
/* Latin1 datas' selection */
|
||||
if (!Db::getInstance()->execute('SET NAMES latin1'))
|
||||
if (!Db::getInstance()->Execute('SET NAMES latin1'))
|
||||
echo 'Cannot change the sql encoding to latin1!';
|
||||
$query = 'SELECT `'.$table['id'].'`';
|
||||
foreach ($table['fields'] AS $field)
|
||||
@@ -94,7 +96,7 @@ function latin1_database_to_utf8()
|
||||
if (isset($table['lang']) AND $table['lang'])
|
||||
$query .= ', `id_lang`';
|
||||
$query .= ' FROM `'._DB_PREFIX_.$table['name'].'`';
|
||||
$latin1Datas = Db::getInstance()->executeS($query);
|
||||
$latin1Datas = Db::getInstance()->ExecuteS($query);
|
||||
if ($latin1Datas === false)
|
||||
{
|
||||
$warningExist = true;
|
||||
@@ -109,7 +111,7 @@ function latin1_database_to_utf8()
|
||||
if (Db::getInstance()->NumRows())
|
||||
{
|
||||
/* Utf-8 datas' restitution */
|
||||
if (!Db::getInstance()->execute('SET NAMES utf8'))
|
||||
if (!Db::getInstance()->Execute('SET NAMES utf8'))
|
||||
echo 'Cannot change the sql encoding to utf8!';
|
||||
foreach ($latin1Datas AS $latin1Data)
|
||||
{
|
||||
@@ -120,7 +122,7 @@ function latin1_database_to_utf8()
|
||||
$query .= ' WHERE `'.$table['id'].'` = '.(int)($latin1Data[$table['id']]);
|
||||
if (isset($table['lang']) AND $table['lang'])
|
||||
$query .= ' AND `id_lang` = '.(int)($latin1Data['id_lang']);
|
||||
if (!Db::getInstance()->execute($query))
|
||||
if (!Db::getInstance()->Execute($query))
|
||||
{
|
||||
$warningExist = true;
|
||||
$requests .= '
|
||||
@@ -26,22 +26,87 @@
|
||||
*/
|
||||
|
||||
function migrate_block_info_to_cms_block()
|
||||
{
|
||||
{
|
||||
$res = true;
|
||||
|
||||
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
|
||||
//get ids cms of block information
|
||||
$id_blockinfos = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = \'blockinfos\'');
|
||||
//get ids cms of block information
|
||||
$ids_cms = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` = '.(int)$id_blockinfos);
|
||||
$ids_cms = Db::getInstance()->executeS('SELECT id_cms FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` = '.(int)$id_blockinfos);
|
||||
//check if block info is installed and active
|
||||
if (sizeof($ids_cms))
|
||||
{
|
||||
//install module blockcms
|
||||
if (Module::getInstanceByName('blockcms')->install())
|
||||
// Module::getInstanceByName('blockcms')->install()
|
||||
// 1) from module
|
||||
$ps_lang_default = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_LANG_DEFAULT"');
|
||||
// 2) parent::install()
|
||||
$result = Db::getInstance()->AutoExecute(_DB_PREFIX_.'module',
|
||||
array('name' => 'blockcms', 'active' => 1), 'INSERT');
|
||||
$id_module = Db::getInstance()->insert_Id();
|
||||
// 3) hooks
|
||||
$hooks = array('leftColumn', 'rightColumn', 'footer', 'header');
|
||||
foreach($hooks as $hook_name)
|
||||
{
|
||||
// do not pSql hook_name
|
||||
$row = Db::getInstance()->getRow('SELECT h.id_hook, '.$id_module.' as id_module, MAX(hm.position)+1 as position
|
||||
FROM `'._DB_PREFIX_.'hook_module` hm
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h on hm.id_hook=h.id_hook
|
||||
WHERE h.name = "'.$hook_name.'" group by id_hook');
|
||||
$res &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'hook_module', $row, 'INSERT');
|
||||
}
|
||||
|
||||
// module install
|
||||
$res &= Db::getInstance()->Execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
|
||||
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_cms_category` int(10) unsigned NOT NULL,
|
||||
`location` tinyint(1) unsigned NOT NULL,
|
||||
`position` int(10) unsigned NOT NULL default \'0\',
|
||||
`display_store` tinyint(1) unsigned NOT NULL default \'1\',
|
||||
PRIMARY KEY (`id_cms_block`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||
$res &= Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)');
|
||||
$res &= Db::getInstance()->Execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`(
|
||||
`id_cms_block` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`name` varchar(40) NOT NULL default \'\',
|
||||
PRIMARY KEY (`id_cms_block`, `id_lang`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||
|
||||
$query_lang = 'INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`) VALUES';
|
||||
foreach ($languages AS $language)
|
||||
$query_lang .= '(1, '.(int)($language['id_lang']).'),';
|
||||
$query_lang = rtrim($query_lang, ',');
|
||||
$res &= Db::getInstance()->Execute($query_lang);
|
||||
|
||||
$res &= Db::getInstance()->Execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`(
|
||||
`id_cms_block_page` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_cms_block` int(10) unsigned NOT NULL,
|
||||
`id_cms` int(10) unsigned NOT NULL,
|
||||
`is_category` tinyint(1) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_cms_block_page`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("FOOTER_CMS", "")');
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("FOOTER_BLOCK_ACTIVATION", "1")');
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("FOOTER_POWEREDBY", "1")');
|
||||
|
||||
//add new block in new cms block
|
||||
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `name`, `location`, `position`) VALUES( 1, \'\', 0, 0)');
|
||||
$id_block = Db::getInstance()->Insert_ID();
|
||||
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block`
|
||||
(`id_cms_category`, `name`, `location`, `position`)
|
||||
VALUES( 1, "", 0, 0)');
|
||||
$id_block = Db::getInstance()->insert_id();
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach($languages AS $language)
|
||||
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`, `name`) VALUES ('.(int)$id_block.', '.(int)$language['id_lang'].', \'Information\')');
|
||||
|
||||
@@ -51,7 +116,4 @@ function migrate_block_info_to_cms_block()
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -41,18 +41,18 @@ function regenerate_level_depth()
|
||||
* @param int $level_depth
|
||||
*/
|
||||
function regenerate_children_categories($id_category, $level_depth)
|
||||
{
|
||||
{
|
||||
$categories = Db::getInstance()->executeS('SELECT `id_category` FROM `'._DB_PREFIX_.'category` WHERE `id_parent` = '.(int)$id_category);
|
||||
if (!$categories)
|
||||
return;
|
||||
$new_depth = (int)$level_depth + 1;
|
||||
$cat_ids = "";
|
||||
foreach($categories as $category)
|
||||
{
|
||||
{
|
||||
$cat_ids .= (string)$category['id_category'].',';
|
||||
regenerate_children_categories($category['id_category'], $new_depth);
|
||||
}
|
||||
}
|
||||
$cat_ids = substr($cat_ids, 0, -1);
|
||||
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'category` SET `level_depth` = '.(int)$new_depth.' WHERE `id_category` IN ('.$cat_ids.')');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,28 +20,44 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7040 $
|
||||
* @version Release: $Revision: 12447 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function reorderpositions()
|
||||
{
|
||||
$res = true;
|
||||
$ps_lang_default = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_LANG_DEFAULT"');
|
||||
/* Clean products positions */
|
||||
if ($cat = Category::getCategories(1, false, false))
|
||||
foreach($cat AS $i => $categ)
|
||||
Product::cleanPositions((int)$categ['id_category']);
|
||||
$cat = Db::getInstance()->executeS('SELECT id_category FROM `'._DB_PREFIX_.'category`');
|
||||
if ($cat)
|
||||
foreach($cat AS $categ)
|
||||
{
|
||||
$id_category = $categ['id_category'];
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT `id_product`
|
||||
FROM `'._DB_PREFIX_.'category_product`
|
||||
WHERE `id_category` = '.$id_category.'
|
||||
ORDER BY `position`');
|
||||
$sizeof = sizeof($result);
|
||||
for ($i = 0; $i < $sizeof; $i++)
|
||||
$res &= Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '.$i.'
|
||||
WHERE `id_category` = '.$id_category.'
|
||||
AND `id_product` = '.(int)($result[$i]['id_product']));
|
||||
}
|
||||
|
||||
//clean Category position and delete old position system
|
||||
Language::loadLanguages();
|
||||
$language = Language::getLanguages();
|
||||
$cat_parent = Db::getInstance()->executeS('SELECT DISTINCT c.id_parent FROM `'._DB_PREFIX_.'category` c WHERE id_category != 1');
|
||||
foreach($cat_parent AS $parent)
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int)(Configuration::get('PS_LANG_DEFAULT')).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$ps_lang_default.')
|
||||
WHERE c.id_parent = '.(int)($parent['id_parent']).'
|
||||
ORDER BY name ASC');
|
||||
foreach($result AS $i => $categ)
|
||||
@@ -69,7 +85,23 @@ function reorderpositions()
|
||||
}
|
||||
|
||||
/* Clean CMS positions */
|
||||
if ($cms_cat = CMSCategory::getCategories(1, false, false))
|
||||
$cms_cat = Db::getInstance()->executeS('SELECT id_cms_category FROM `'._DB_PREFIX_.'cms_category` WHERE active=1');
|
||||
if ($cms_cat)
|
||||
foreach($cms_cat AS $i => $categ)
|
||||
CMS::cleanPositions((int)($categ['id_cms_category']));
|
||||
{
|
||||
$id_category_parent = $categ['id_cms_category'];
|
||||
$result &= Db::getInstance()->executeS('
|
||||
SELECT `id_cms_category`
|
||||
FROM `'._DB_PREFIX_.'cms_category`
|
||||
WHERE `id_parent` = '.(int)$id_category_parent.'
|
||||
ORDER BY `position`');
|
||||
$sizeof = sizeof($result);
|
||||
for ($i = 0; $i < $sizeof; ++$i){
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'cms_category`
|
||||
SET `position` = '.(int)$i.'
|
||||
WHERE `id_parent` = '.(int)$id_category_parent.'
|
||||
AND `id_cms_category` = '.(int)$result[$i]['id_cms_category'];
|
||||
$res &= Db::getInstance()->Execute($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function setAllGroupsOnHomeCategory()
|
||||
{
|
||||
$ps_lang_default = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'`configuration WHERE name="PS_LANG_DEFAULT"');
|
||||
|
||||
$results = Db::getInstance()->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group`');
|
||||
$groups = array();
|
||||
foreach ($results AS $result)
|
||||
$groups[] = $result['id_group'];
|
||||
|
||||
if (is_array($groups) && sizeof($groups))
|
||||
{
|
||||
// cleanGroups
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category_group`
|
||||
WHERE `id_category` = 1');
|
||||
// addGroups($groups);
|
||||
$row = array('id_category' => 1, 'id_group' => (int)($groups));
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'category_group', $row, 'INSERT');
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -20,18 +20,16 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function set_discount_category()
|
||||
{
|
||||
$discounts = Db::getInstance()->executeS('SELECT `id_discount` FROM `'._DB_PREFIX_.'discount`');
|
||||
$categories = Db::getInstance()->executeS('SELECT `id_category` FROM `'._DB_PREFIX_.'category`');
|
||||
$discounts = Db::getInstance()->ExecuteS('SELECT `id_discount` FROM `'._DB_PREFIX_.'discount`');
|
||||
$categories = Db::getInstance()->ExecuteS('SELECT `id_category` FROM `'._DB_PREFIX_.'category`');
|
||||
foreach ($discounts AS $discount)
|
||||
foreach ($categories AS $category)
|
||||
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'discount_category` (`id_discount`,`id_category`) VALUES ('.(int)($discount['id_discount']).','.(int)($category['id_category']).')');
|
||||
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'discount_category` (`id_discount`,`id_category`) VALUES ('.(int)($discount['id_discount']).','.(int)($category['id_category']).')');
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -40,10 +40,10 @@ function set_payment_module()
|
||||
$content = fread($fd, filesize($file));
|
||||
if (preg_match_all('/extends PaymentModule/U', $content, $matches))
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'module_country` (id_module, id_country)
|
||||
SELECT '.(int)($module['id_module']).', id_country FROM `'._DB_PREFIX_.'country` WHERE active = 1');
|
||||
Db::getInstance()->execute('
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'module_currency` (id_module, id_currency)
|
||||
SELECT '.(int)($module['id_module']).', id_currency FROM `'._DB_PREFIX_.'currency` WHERE deleted = 0');
|
||||
}
|
||||
+2
-2
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ function set_payment_module_group()
|
||||
$content = fread($fd, filesize($file));
|
||||
if (preg_match_all('/extends PaymentModule/U', $content, $matches))
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'module_group` (id_module, id_group)
|
||||
SELECT '.(int)($module['id_module']).', id_group FROM `'._DB_PREFIX_.'group`');
|
||||
}
|
||||
@@ -27,9 +27,14 @@
|
||||
|
||||
function shop_url()
|
||||
{
|
||||
if (!($host = Configuration::get('CANONICAL_URL')))
|
||||
$host = Tools::getHttpHost();
|
||||
Configuration::updateValue('PS_SHOP_DOMAIN', $host);
|
||||
Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $host);
|
||||
$host = Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="CANONICAL_URL"');
|
||||
if (!$host)
|
||||
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
|
||||
$res = Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES
|
||||
("PS_SHOP_DOMAIN", "'.$host.'"),
|
||||
("PS_SHOP_DOMAIN_SSL", "'.$host.'")
|
||||
');
|
||||
return true;
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 12447 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 8754 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function update_feature_detachable_cache()
|
||||
{
|
||||
if (!class_exists('Configuration', false))
|
||||
{
|
||||
if (!class_exists('ObjectModel', false))
|
||||
{
|
||||
require_once(_PS_CLASS_DIR_.'/ObjectModel.php');
|
||||
eval('class ObjectModel extends ObjectModelCore{}');
|
||||
|
||||
}
|
||||
require_once(_PS_CLASS_DIR_.'/Configuration.php');
|
||||
eval('class Configuration extends ConfigurationCore{}');
|
||||
}
|
||||
|
||||
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', (int)SpecificPrice::isCurrentlyUsed('specific_price'));
|
||||
Configuration::updateGlobalValue('PS_SCENE_FEATURE_ACTIVE', (int)Scene::isCurrentlyUsed('scene', true));
|
||||
Configuration::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', (int)ProductDownload::isCurrentlyUsed('product_download', true));
|
||||
Configuration::updateGlobalValue('PS_CUSTOMIZATION_FEATURE_ACTIVE', (int)Customization::isCurrentlyUsed());
|
||||
Configuration::updateGlobalValue('PS_DISCOUNT_FEATURE_ACTIVE', (int)Discount::isCurrentlyUsed('discount', true));
|
||||
Configuration::updateGlobalValue('PS_GROUP_FEATURE_ACTIVE', (int)Group::isCurrentlyUsed());
|
||||
Configuration::updateGlobalValue('PS_PACK_FEATURE_ACTIVE', (int)Pack::isCurrentlyUsed());
|
||||
Configuration::updateGlobalValue('PS_ALIAS_FEATURE_ACTIVE', (int)Alias::isCurrentlyUsed('alias', true));
|
||||
}
|
||||
@@ -8,9 +8,12 @@ function update_for_13version()
|
||||
return; // if the old version is a 1.4 version
|
||||
|
||||
// Disable the Smarty 3
|
||||
Configuration::updateValue('PS_FORCE_SMARTY_2', 1);
|
||||
// Disable the URL rewritting
|
||||
Configuration::updateValue('PS_REWRITING_SETTINGS', 0);
|
||||
// Disable Canonical redirection
|
||||
Configuration::updateValue('PS_CANONICAL_REDIRECT', 0);
|
||||
$res = Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES
|
||||
("PS_FORCE_SMARTY_2", "1"),
|
||||
("PS_REWRITING_SETTINGS", "0")
|
||||
("PS_CANONICAL_REDIRECT", "0")
|
||||
');
|
||||
}
|
||||
@@ -27,9 +27,8 @@
|
||||
|
||||
function update_module_followup()
|
||||
{
|
||||
Configuration::loadConfiguration();
|
||||
$followup = Module::getInstanceByName('followup');
|
||||
if (!$followup->id)
|
||||
$id_followup = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "followup"');
|
||||
if (!$id_followup)
|
||||
return;
|
||||
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'log_email` ADD INDEX `date_add`(`date_add`), ADD INDEX `id_cart`(`id_cart`);');
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 12447 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -28,17 +28,21 @@
|
||||
// backward compatibility vouchers should be available in all categories
|
||||
function update_module_loyalty()
|
||||
{
|
||||
if (Configuration::get('PS_LOYALTY_POINT_VALUE') !== false)
|
||||
$ps_loyalty_point_value = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_LOYALTY_POINT_VALUE"');
|
||||
if ($ps_loyalty_point_value !== false)
|
||||
{
|
||||
$category_list = '';
|
||||
|
||||
foreach(Category::getSimpleCategories(Configuration::get('PS_LANG_DEFAULT')) as $category)
|
||||
$categories = Db::getInstance('SELECT id_category FROM `'._DB_PREFIX_.'category`');
|
||||
foreach($categories as $category)
|
||||
$category_list .= $category['id_category'].',';
|
||||
|
||||
if (!empty($category_list))
|
||||
{
|
||||
$category_list = rtrim($category_list, ',');
|
||||
Configuration::updateValue('PS_LOYALTY_VOUCHER_CATEGORY', $category_list);
|
||||
$res &= Db::getInstance()->execute('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("PS_LOYALTY_VOUCHER_CATEGORY", "'.$category_list.'"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-10
@@ -20,22 +20,21 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function update_modules_sql()
|
||||
{
|
||||
Configuration::loadConfiguration();
|
||||
$blocklink = Module::getInstanceByName('blocklink');
|
||||
if ($blocklink->id)
|
||||
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'blocklink_lang` ADD PRIMARY KEY (`id_link`, `id_lang`);');
|
||||
$productComments = Module::getInstanceByName('productcomments');
|
||||
if ($productComments->id)
|
||||
$id_blocklink = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "blocklink"');
|
||||
if ($id_blocklink)
|
||||
Db::getInstance()->Execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'blocklink_lang` ADD PRIMARY KEY (`id_link`, `id_lang`);');
|
||||
$id_productcomments = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "productcomments"');
|
||||
if ($id_productcomments)
|
||||
{
|
||||
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_grade` ADD PRIMARY KEY (`id_product_comment`, `id_product_comment_criterion`);');
|
||||
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_criterion` DROP PRIMARY KEY, ADD PRIMARY KEY (`id_product_comment_criterion`, `id_lang`);');
|
||||
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_criterion_product` ADD PRIMARY KEY(`id_product`, `id_product_comment_criterion`);');
|
||||
Db::getInstance()->Execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_grade` ADD PRIMARY KEY (`id_product_comment`, `id_product_comment_criterion`);');
|
||||
Db::getInstance()->Execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_criterion` DROP PRIMARY KEY, ADD PRIMARY KEY (`id_product_comment_criterion`, `id_lang`);');
|
||||
Db::getInstance()->Execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment_criterion_product` ADD PRIMARY KEY(`id_product`, `id_product_comment_criterion`);');
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,12 @@
|
||||
|
||||
function update_order_canada()
|
||||
{
|
||||
$sql ='SHOW TABLES LIKE \''._DB_PREFIX_.'order_tax\'';
|
||||
$table = Db::getInstance()->ExecuteS($sql);
|
||||
$sql ='SHOW TABLES LIKE "'._DB_PREFIX_.'order_tax"';
|
||||
$table = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (!count($table))
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
Db::getInstance()->execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'order_tax` (
|
||||
`id_order` int(11) NOT NULL,
|
||||
`tax_name` varchar(40) NOT NULL,
|
||||
@@ -41,46 +41,56 @@ function update_order_canada()
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8');
|
||||
|
||||
|
||||
$address_field = Configuration::get('PS_TAX_ADDRESS_TYPE');
|
||||
$address_field = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_TAX_ADDRESS_TYPE"');
|
||||
$address_field = str_replace('`','\`', $address_field);
|
||||
|
||||
$sql = 'SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` a ON (a.`id_address` = o.`'.bqSQL($address_field).'`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` cus ON (o.id_customer = cus.id_customer)
|
||||
LEFT JOIN `'._DB_PREFIX_.'group` g ON (g.id_group = cus.id_default_group)
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` a ON (a.`id_address` = o.`'.$address_field.'`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.`id_country` = a.`id_country`)
|
||||
WHERE c.`iso_code` = "CA"';
|
||||
|
||||
$id_order_list = Db::getInstance()->ExecuteS($sql);
|
||||
|
||||
$id_order_list = Db::getInstance()->executeS($sql);
|
||||
$default_price_display_method = Db::getInstance()->getValue('SELECT price_display_method
|
||||
FROM `'._DB_PREFIX_.'group WHERE id_group=1`');
|
||||
$values = '';
|
||||
foreach ($id_order_list as $id_order)
|
||||
foreach ($id_order_list as $order)
|
||||
{
|
||||
$amount = array();
|
||||
$id_order = $id_order['id_order'];
|
||||
$order = new Order((int)$id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
continue;
|
||||
$id_order = $order['id_order'];
|
||||
// in Order class, getTaxCalculationMethod
|
||||
// returns Group::getDefaultPriceDisplayMethod
|
||||
$tax_calculation_method = $order['price_display_method'];
|
||||
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'order_detail` od
|
||||
WHERE od.`id_order` = '.(int)$id_order);
|
||||
|
||||
$products = $order->getProducts();
|
||||
foreach ($products as $product)
|
||||
{
|
||||
if (!array_key_exists($product['tax_name'], $amount))
|
||||
$amount[$product['tax_name']] = array('amount' => 0, 'rate' => $product['tax_rate']);
|
||||
|
||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
||||
if ($tax_calculation_method == PS_TAX_EXC)
|
||||
{
|
||||
$total_product = $product['product_price'] * $product['product_quantity'];
|
||||
$amount_tmp = Tools::ps_round($total_product * ($product['tax_rate'] / 100), 2);
|
||||
$amount[$product['tax_name']]['amount'] += Tools::ps_round($total_product * ($product['tax_rate'] / 100), 2);
|
||||
$amount_tmp = update_order_canada_ps_round($total_product * ($product['tax_rate'] / 100), 2);
|
||||
$amount[$product['tax_name']]['amount'] += update_order_canada_ps_round($total_product * ($product['tax_rate'] / 100), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$total_product = $product['product_price'] * $product['product_quantity'];
|
||||
$amount_tmp = Tools::ps_round($total_product - ($total_product / (1 + ($product['tax_rate'] / 100))), 2);
|
||||
$amount[$product['tax_name']]['amount'] += Tools::ps_round($total_product - ($total_product / (1 + ($product['tax_rate'] / 100))), 2);
|
||||
$amount_tmp = update_order_canada_ps_round($total_product - ($total_product / (1 + ($product['tax_rate'] / 100))), 2);
|
||||
$amount[$product['tax_name']]['amount'] += update_order_canada_ps_round($total_product - ($total_product / (1 + ($product['tax_rate'] / 100))), 2);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($amount as $tax_name => $tax_infos)
|
||||
$values .= '('.(int)$order->id.', \''.pSQL($tax_name).'\', \''.pSQL($tax_infos['rate']).'\', '.(float)$tax_infos['amount'].'),';
|
||||
$values .= '('.(int)$id_order.', "'.$tax_name.'\', "'.$tax_infos['rate'].'", '.(float)$tax_infos['amount'].'),';
|
||||
unset($order);
|
||||
}
|
||||
|
||||
@@ -95,3 +105,23 @@ function update_order_canada()
|
||||
}
|
||||
}
|
||||
|
||||
function update_order_canada_ps_round($val){
|
||||
static $ps_price_round_mode;
|
||||
if (empty($ps_price_round_mode))
|
||||
{
|
||||
$ps_price_round_mode = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name = "PS_PRICE_ROUND_MODE"');
|
||||
}
|
||||
|
||||
switch ($ps_price_round_mode)
|
||||
{
|
||||
case PS_ROUND_UP:
|
||||
return ceil($val * 100)/100;
|
||||
case PS_ROUND_DOWN:
|
||||
return floor($val * 100)/100;
|
||||
default:
|
||||
return round($val, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 6594 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -31,8 +31,8 @@ function update_order_details()
|
||||
|
||||
if (sizeof($res) == 0)
|
||||
{
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_percent` DECIMAL(10, 2) NOT NULL default \'0.00\' AFTER `product_price`');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_amount` DECIMAL(20, 6) NOT NULL default \'0.000000\' AFTER `reduction_percent`');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_percent` DECIMAL(10, 2) NOT NULL default "0.00" AFTER `product_price`');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_amount` DECIMAL(20, 6) NOT NULL default "0.000000" AFTER `reduction_percent`');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
function update_products_ecotax_v133()
|
||||
{
|
||||
global $oldversion;
|
||||
if($oldversion < '1.3.3.0')
|
||||
if ($oldversion < '1.3.3.0')
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `ecotax` = \'0\' WHERE 1');
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'order_detail` SET `ecotax` = \'0\' WHERE 1;');
|
||||
|
||||
Reference in New Issue
Block a user