' . "\n";
if ($lC_Product->hasImage()) {
diff --git a/catalog/includes/modules/content/specials.php b/catalog/includes/modules/content/specials.php
new file mode 100644
index 000000000..dd33a9029
--- /dev/null
+++ b/catalog/includes/modules/content/specials.php
@@ -0,0 +1,109 @@
+injectDefinitions)) $lC_Language->injectDefinitions('modules/' . $_GET['set'] . '/' . $this->_code . '.xml');
+
+ $this->_title = $lC_Language->get('specials_title');
+ }
+ /*
+ * Returns the specials HTML
+ *
+ * @access public
+ * @return string
+ */
+ public function initialize() {
+ global $lC_Database, $lC_Cache, $lC_Language, $lC_Currencies, $lC_Image, $current_category_id;
+
+ $data = array();
+
+ if ( ($lC_Cache->isEnabled() && MODULE_CONTENT_SPECIALS_CACHE > 0) && $lC_Cache->read('specials-' . $lC_Language->getCode() . '-' . $lC_Currencies->getCode() . '-' . $current_category_id, MODULE_CONTENT_SPECIALS_CACHE) ) {
+ $data = $lC_Cache->getCache();
+ } else {
+ $Qproducts = $lC_Database->query('select distinct p.products_id, pi.image, pd.products_name from :table_products p, :table_products_images pi, :table_products_description pd, :table_specials s where p.products_status = :products_status and p.is_subproduct = :is_subproduct and s.status = :specials_status and p.products_id = s.products_id and pi.id = s.products_id and pd.products_id = s.products_id order by rand() limit :max_display_specials');
+ $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproducts->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
+ $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qproducts->bindTable(':table_specials', TABLE_SPECIALS);
+ $Qproducts->bindInt(':products_status', 1);
+ $Qproducts->bindInt(':is_subproduct', 0);
+ $Qproducts->bindInt(':specials_status', 1);
+ $Qproducts->bindInt(':max_display_specials', MODULE_CONTENT_SPECIALS_MAX_DISPLAY);
+ $Qproducts->execute();
+
+ while ( $Qproducts->next() ) {
+ // VQMOD-hookpoint; DO NOT MODIFY OR REMOVE THE LINE BELOW
+ $lC_Product = new lC_Product($Qproducts->valueInt('products_id'));
+
+ $data[$lC_Product->getID()] = $lC_Product->getData();
+ $data[$lC_Product->getID()]['display_price'] = $lC_Product->getPriceFormated(true);
+ $data[$lC_Product->getID()]['display_image'] = $lC_Product->getImage();
+ }
+
+ if ($lC_Cache->isEnabled()) $lC_Cache->write($data);
+ }
+
+ if ( !empty($data) ) {
+
+ $this->_content = '';
+ foreach ( $data as $product ) {
+ $this->_content .= '
' . "\n";
+ $this->_content .= '
' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $product['keyword']), $lC_Image->show($product['display_image'], $product['name'], 'class="content-specials-image-src"')) . '
' . "\n" .
+ '
' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $product['keyword']), $product['name']) . '
' . "\n" .
+ '
' . ((strlen(lc_clean_html($product['description'])) > 65) ? substr(lc_clean_html($product['description']), 0, 62) . '...' : lc_clean_html($product['description'])) . '
' . "\n" .
+ '
' . $product['display_price']. '
' . "\n" .
+ '
' . "\n";
+ $this->_content .= '
' . "\n";
+ }
+ }
+ }
+
+ /*
+ * Install the module
+ *
+ * @access public
+ * @return void
+ */
+ public function install() {
+ global $lC_Database;
+
+ parent::install();
+
+ $lC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Entries To Display', 'MODULE_CONTENT_SPECIALS_MAX_DISPLAY', '9', 'Maximum number of specials to display', '6', '0', now())");
+ $lC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Cache Contents', 'MODULE_CONTENT_SPECIALS_CACHE', '60', 'Number of minutes to keep the contents cached (0 = no cache)', '6', '0', now())");
+ }
+ /*
+ * Return the module keys
+ *
+ * @access public
+ * @return array
+ */
+ public function getKeys() {
+ if (!isset($this->_keys)) {
+ $this->_keys = array('MODULE_CONTENT_SPECIALS_MAX_DISPLAY', 'MODULE_CONTENT_SPECIALS_CACHE');
+ }
+
+ return $this->_keys;
+ }
+}
+?>
\ No newline at end of file
diff --git a/catalog/includes/modules/product_listing.php b/catalog/includes/modules/product_listing.php
index a03110219..f1ed625d6 100644
--- a/catalog/includes/modules/product_listing.php
+++ b/catalog/includes/modules/product_listing.php
@@ -61,7 +61,7 @@
case 'PRODUCT_LIST_MANUFACTURER':
if ( $lC_Product->hasManufacturer() ) {
- $output .= '
getManufacturerID()), $lC_Product->getManufacturer()) . '
' . "\n";
} else {
$output .= '
' . "\n";
}
diff --git a/catalog/includes/version.txt b/catalog/includes/version.txt
index e5024eca0..4f027cdc9 100644
--- a/catalog/includes/version.txt
+++ b/catalog/includes/version.txt
@@ -1 +1 @@
-7.003.3.3|04/21/2015
+7.003.4.0|06/15/2015
diff --git a/catalog/includes/work/updates/runAfter/controller.php b/catalog/includes/work/updates/runAfter/controller.php
index 2775ad5b5..a9e24d1ba 100644
--- a/catalog/includes/work/updates/runAfter/controller.php
+++ b/catalog/includes/work/updates/runAfter/controller.php
@@ -422,8 +422,8 @@ public static function updateDB() {
$lC_Database->simpleQuery("CREATE TABLE IF NOT EXISTS `" . $pf . "purchase_orders_service` (`po_number_id` int(11) NOT NULL AUTO_INCREMENT, `po_number` varchar(255) NOT NULL, `orders_id` int(11) NOT NULL, `po_number_status` int(1) NOT NULL DEFAULT '1', PRIMARY KEY (`po_number_id`)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci");
parent::log("Database Update: CREATE TABLE IF NOT EXISTS `" . $pf . "purchase_orders_service` (`po_number_id` int(11) NOT NULL AUTO_INCREMENT, `po_number` varchar(255) NOT NULL, `orders_id` int(11) NOT NULL, `po_number_status` int(1) NOT NULL DEFAULT '1', PRIMARY KEY (`po_number_id`)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci");
- $lC_Database->simpleQuery("ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_status` TINYINT(1) NOT NULL DEFAULT '-1'");
- parent::log("Database Update: ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_status` TINYINT(1) NOT NULL DEFAULT '-1'");
+ $lC_Database->simpleQuery("ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_status` INT(11) NOT NULL DEFAULT '-1'");
+ parent::log("Database Update: ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_status` INT(11) NOT NULL DEFAULT '-1'");
$lC_Database->simpleQuery("ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_price` DECIMAL(15,4) NOT NULL DEFAULT '0.0000'");
parent::log("Database Update: ALTER IGNORE TABLE `" . $pf . "products_pricing` ADD `group_price` DECIMAL(15,4) NOT NULL DEFAULT '0.0000'");
@@ -469,7 +469,29 @@ public static function updateDB() {
$lC_Database->simpleQuery("ALTER IGNORE TABLE `" . $pf . "product_attributes` ADD `value2` TEXT NOT NULL AFTER `value`");
parent::log("Database Update: ALTER IGNORE TABLE `" . $pf . "product_attributes` ADD `value2` TEXT NOT NULL AFTER `value`");
-
+
+ $lC_Database->simpleQuery("CREATE TABLE IF NOT EXISTS `" . $pf . "localization` (id int(11) NOT NULL AUTO_INCREMENT, domain varchar(255) NOT NULL, alt_domain tinyint(1) NOT NULL DEFAULT '0', currencies_id int(11) NOT NULL DEFAULT '0', language_id int(11) NOT NULL DEFAULT '0', show_tax tinyint(1) NOT NULL DEFAULT '0', default_tax_zone int(11) NOT NULL DEFAULT '0', base_price_modifier decimal(15,4) NOT NULL DEFAULT '0', `status` tinyint(1) NOT NULL DEFAULT '1', id int(11) NOT NULL AUTO_INCREMENT, domain varchar(255) NOT NULL, alt_domain tinyint(1) NOT NULL DEFAULT '0', currencies_id int(11) NOT NULL, language_id int(11) NOT NULL, show_tax tinyint(1) NOT NULL, default_tax_zone int(11) NOT NULL, base_price_modifier decimal(15,4) NOT NULL DEFAULT '0', `status` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (id)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci;");
+ parent::log("Database Update: CREATE TABLE IF NOT EXISTS `" . $pf . "localization` (id int(11) NOT NULL AUTO_INCREMENT, domain varchar(255) NOT NULL, alt_domain tinyint(1) NOT NULL DEFAULT '0', currencies_id int(11) NOT NULL DEFAULT '0', language_id int(11) NOT NULL DEFAULT '0', show_tax tinyint(1) NOT NULL DEFAULT '0', default_tax_zone int(11) NOT NULL DEFAULT '0', base_price_modifier decimal(15,4) NOT NULL DEFAULT '0', `status` tinyint(1) NOT NULL DEFAULT '1', id int(11) NOT NULL AUTO_INCREMENT, domain varchar(255) NOT NULL, alt_domain tinyint(1) NOT NULL DEFAULT '0', currencies_id int(11) NOT NULL, language_id int(11) NOT NULL, show_tax tinyint(1) NOT NULL, default_tax_zone int(11) NOT NULL, base_price_modifier decimal(15,4) NOT NULL DEFAULT '0', `status` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (id)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci;");
+
+ $lC_Database->simpleQuery("CREATE TABLE IF NOT EXISTS `" . $pf . "customers_access` ( id int(11) NOT NULL AUTO_INCREMENT, `level` varchar(128) NOT NULL, `status` tinyint(1) NOT NULL, PRIMARY KEY (id)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci;");
+ parent::log("Database Update: CREATE TABLE IF NOT EXISTS `" . $pf . "customers_access` ( id int(11) NOT NULL AUTO_INCREMENT, `level` varchar(128) NOT NULL, `status` tinyint(1) NOT NULL, PRIMARY KEY (id)) ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_general_ci;");
+
+ $Qchk = $lC_Database->query('select * from :table_customers_access")');
+ $Qchk->bindTable(':table_customers_access', $pf . "customers_access");
+ $Qchk->execute();
+
+ if ($Qchk->numberOfRows() == 0) {
+ $lC_Database->simpleQuery("INSERT INTO `" . $pf . "customers_access` (id, level, status) VALUES (1, 'Guest', '1')");
+ parent::log("Database Update: INSERT INTO `" . $pf . "customers_access` (id, level, status) VALUES (1, 'Guest', '1')");
+ $lC_Database->simpleQuery("INSERT INTO `" . $pf . "customers_access` (id, level, status) VALUES (2, 'Registered', '1')");
+ parent::log("Database Update: INSERT INTO `" . $pf . "customers_access` (id, level, status) VALUES (2, 'Registered', '1')");
+ }
+
+ if (!defined('PRODUCT_LISTING_DISPLAY_ORDER')) {
+ $lC_Database->simpleQuery("INSERT INTO `" . $pf . "configuration` (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES('Products Display Order', 'PRODUCT_LISTING_DISPLAY_ORDER', 'Name', 'Products displayed on listing pages are ordered by this value.', 8, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''Name'', ''Model'', ''Price'', ''Manufacturer'', ''Quantity'', ''Weight'', ''Last Added'', ''Sort Order''))');");
+ parent::log("Database Update: INSERT INTO `" . $pf . "configuration` (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES('Products Display Order', 'PRODUCT_LISTING_DISPLAY_ORDER', 'Name', 'Products displayed on listing pages are ordered by this value.', 8, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''Name'', ''Model'', ''Price'', ''Manufacturer'', ''Quantity'', ''Weight'', ''Last Added'', ''Sort Order''))');");
+ }
+
}
}
?>
\ No newline at end of file
diff --git a/catalog/install/includes/classes/upgrader.php b/catalog/install/includes/classes/upgrader.php
index 11e4a6027..5ada84c77 100644
--- a/catalog/install/includes/classes/upgrader.php
+++ b/catalog/install/includes/classes/upgrader.php
@@ -510,6 +510,7 @@ public function __construct() {
, 'manufacturers_id' => 'manufacturers_id'
, 'products_ordered' => 'products_ordered'
, 'has_children' => 'has_children'
+ , 'products_sort_order' => 'sort_order'
)
, 'products_desc' => array(
'products_id' => 'products_id'
@@ -632,6 +633,14 @@ public function __construct() {
, 'last_modified' => 'last_modified'
, 'date_added' => 'date_added'
)
+ , 'featured' => array(
+ 'id' => 'featured_id'
+ , 'products_id' => 'products_id'
+ , 'date_added' => 'featured_date_added'
+ , 'last_modified' => 'featured_last_modified'
+ , 'expires_date' => 'expires_date'
+ , 'status' => 'status'
+ )
);
}
@@ -670,7 +679,7 @@ public function showConnectInfo() {
/*
* function name : importProducts()
*
- * description : load products, products_description, products_to_categories, products_notifications, manufacturers, reviews and specials from the source database to loaded7
+ * description : load products from the source database to loaded7
*
* returns : true or false
*
@@ -722,29 +731,8 @@ public function importProducts($switch = null) {
$tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS);
$tQry->execute();
- $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_DESCRIPTION);
- $tQry->execute();
-
$tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_PRICING);
$tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_NOTIFICATIONS);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_TO_CATEGORIES);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_MANUFACTURERS);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_MANUFACTURERS_INFO);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_REVIEWS);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_SPECIALS);
- $tQry->execute();
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
@@ -802,9 +790,8 @@ public function importProducts($switch = null) {
, 'products_price10_qty' => $sQry->value('products_price10_qty')
, 'products_price11_qty' => $sQry->value('products_price11_qty')
, 'has_children' => 0
- );
-
- $products[] = $product;
+ , 'products_sort_order' => $sQry->value($map['products_sort_order'])
+ );
$tQry = $target_db->query('INSERT INTO :table_products (products_id,
parent_id,
@@ -823,6 +810,7 @@ public function importProducts($switch = null) {
manufacturers_id,
products_ordered,
has_children,
+ products_sort_order,
is_subproduct)
VALUES (:products_id,
:parent_id,
@@ -841,6 +829,7 @@ public function importProducts($switch = null) {
:manufacturers_id,
:products_ordered,
:has_children,
+ :products_sort_order,
:is_subproduct)');
$tQry->bindTable(':table_products', TABLE_PRODUCTS);
@@ -856,11 +845,12 @@ public function importProducts($switch = null) {
$tQry->bindDate (':products_last_modified', $product['products_last_modified']);
$tQry->bindFloat(':products_weight' , $product['products_weight']);
$tQry->bindValue(':products_weight_class' , $product['products_weight_class']);
- $tQry->bindInt (':products_status' , $product['products_status']);
+ $tQry->bindInt (':products_status' , 1);
$tQry->bindInt (':products_tax_class_id' , $product['products_tax_class_id']);
$tQry->bindInt (':manufacturers_id' , $product['manufacturers_id']);
$tQry->bindInt (':products_ordered' , $product['products_ordered']);
$tQry->bindInt (':has_children' , $product['has_children']);
+ $tQry->bindInt (':products_sort_order' , $product['products_sort_order']);
$tQry->bindInt (':is_subproduct' , ($product['parent_id'] != 0) ? 1 : 0);
$tQry->execute();
@@ -1110,21 +1100,34 @@ public function importProducts($switch = null) {
$mQry = $target_db->query('SELECT id FROM :table_templates_boxes WHERE code = "manufacturers"');
$mQry->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
$mQry->execute();
+
+ // Added for default values fix during upgrade - START
+ $dvQry = $target_db->query('ALTER TABLE :table_product_attributes ALTER COLUMN value SET DEFAULT ""');
+ $dvQry->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
+ $dvQry->execute();
+
+ $dv2Qry = $target_db->query('ALTER TABLE :table_product_attributes ALTER COLUMN value2 SET DEFAULT ""');
+ $dv2Qry->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
+ $dv2Qry->execute();
+ // Added for default values fix during upgrade - end
$aQry = $target_db->query('INSERT INTO :table_product_attributes (id,
products_id,
languages_id,
- value)
+ value,
+ value2)
VALUES (:id,
:products_id,
:languages_id,
- :value)');
+ :value,
+ :value2)');
$aQry->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
$aQry->bindInt(':id' , $mQry->value('id'));
$aQry->bindInt(':products_id' , $sQry->value($map['products_id']));
$aQry->bindInt(':languages_id' , 0);
$aQry->bindInt(':value' , ($sQry->value($map['manufacturers_id']) != '' || $sQry->value($map['manufacturers_id']) != NULL) ? $sQry->value($map['manufacturers_id']) : 0);
+ $aQry->bindInt(':value2' , '');
$aQry->execute();
if ($target_db->isError()) {
@@ -1150,14 +1153,89 @@ public function importProducts($switch = null) {
// END LOAD PRODUCTS FROM SOURCE DB
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
+
+ } // end importProducts
+
+ /*
+ * function name : importProductsDescription()
+ *
+ * description : load products_description and permalink from the source database to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importProductsDescription($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE PRODUCTS DESCRIPTION TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_DESCRIPTION);
+ $tQry->execute();
+
+ // END TRUNCATE PRODUCTS DESCRIPTION TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
// LOAD PRODUCTS DESCRIPTION FROM SOURCE DB
$map = $this->_data_mapping['products_desc'];
- $products_desc = array();
-
$sQry = $source_db->query('SELECT * FROM products_description');
$sQry->execute();
+
+ $products_desc = array();
if ($sQry->numberOfRows() > 0) {
$cnt = 0;
@@ -1175,8 +1253,8 @@ public function importProducts($switch = null) {
, 'products_url' => ($sQry->value($map['products_url']) != '' || $sQry->value($map['products_url']) != NULL) ? $sQry->value($map['products_url']) : ""
, 'products_viewed' => ($sQry->value($map['products_viewed']) != '' || $sQry->value($map['products_viewed']) != NULL) ? $sQry->value($map['products_viewed']) : ""
);
-
- $products_desc[] = $product;
+
+ $products_desc[] = $product;
$cnt++;
}
@@ -1208,40 +1286,40 @@ public function importProducts($switch = null) {
$tQry = $target_db->query('INSERT INTO :table_products_description (products_id,
- language_id,
- products_name,
- products_description,
- products_keyword,
- products_tags,
- products_meta_title,
- products_meta_keywords,
- products_meta_description,
- products_url,
- products_viewed)
- VALUES (:products_id,
- :language_id,
- :products_name,
- :products_description,
- :products_keyword,
- :products_tags,
- :products_meta_title,
- :products_meta_keywords,
- :products_meta_description,
- :products_url,
- :products_viewed)');
+ language_id,
+ products_name,
+ products_description,
+ products_keyword,
+ products_tags,
+ products_meta_title,
+ products_meta_keywords,
+ products_meta_description,
+ products_url,
+ products_viewed)
+ VALUES (:products_id,
+ :language_id,
+ :products_name,
+ :products_description,
+ :products_keyword,
+ :products_tags,
+ :products_meta_title,
+ :products_meta_keywords,
+ :products_meta_description,
+ :products_url,
+ :products_viewed)');
$tQry->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
- $tQry->bindInt (':products_id' , $product['products_id']);
- $tQry->bindInt (':language_id' , $product['language_id']);
- $tQry->bindValue(':products_name' , $product['products_name']);
- $tQry->bindValue(':products_description' , $product['products_description']);
- $tQry->bindValue(':products_keyword' , $permalink);
- $tQry->bindValue(':products_tags' , $product['products_tags']);
- $tQry->bindValue(':products_meta_title' , $product['products_meta_title']);
- $tQry->bindValue(':products_meta_keywords' , $product['products_meta_keywords']);
- $tQry->bindValue(':products_meta_description', $product['products_meta_description']);
- $tQry->bindValue(':products_url' , $product['products_url']);
- $tQry->bindInt (':products_viewed' , $product['products_viewed']);
+ $tQry->bindInt (':products_id' , $product['products_id']);
+ $tQry->bindInt (':language_id' , $product['language_id']);
+ $tQry->bindValue(':products_name' , $product['products_name']);
+ $tQry->bindValue(':products_description' , $product['products_description']);
+ $tQry->bindValue(':products_keyword' , $permalink);
+ $tQry->bindValue(':products_tags' , $product['products_tags']);
+ $tQry->bindValue(':products_meta_title' , $product['products_meta_title']);
+ $tQry->bindValue(':products_meta_keywords' , $product['products_meta_keywords']);
+ $tQry->bindValue(':products_meta_description' , $product['products_meta_description']);
+ $tQry->bindValue(':products_url' , $product['products_url']);
+ $tQry->bindInt (':products_viewed' , $product['products_viewed']);
$tQry->execute();
if ($target_db->isError()) {
@@ -1254,114 +1332,23 @@ public function importProducts($switch = null) {
// END LOAD PRODUCTS DESCRIPTION TO TARGET DB
- // ##########
-
- // LOAD PRODUCTS NOTIFICATIONS FROM SOURCE DB
-
- $map = $this->_data_mapping['products_notif'];
-
- $products_notifs = array();
-
- $sQry = $source_db->query('SELECT * FROM products_notifications');
- $sQry->execute();
-
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $product = array(
- 'products_id' => $sQry->value($map['products_id'])
- , 'customers_id' => $sQry->value($map['customers_id'])
- , 'date_added' => ($sQry->value($map['date_added']) != '' || $sQry->value($map['date_added']) != NULL) ? $sQry->value($map['date_added']) : ""
- );
-
- $products_notifs[] = $product;
-
-
- $tQry = $target_db->query('INSERT INTO :table_products_notifs (products_id,
- customers_id,
- date_added)
- VALUES (:products_id,
- :customers_id,
- :date_added)');
-
- $tQry->bindTable(':table_products_notifs', TABLE_PRODUCTS_NOTIFICATIONS);
- $tQry->bindInt (':products_id' , $product['products_id']);
- $tQry->bindInt (':customers_id', $product['customers_id']);
- $tQry->bindDate (':date_added' , $product['date_added']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $cnt++;
- }
-
- $sQry->freeResult();
- }
-
- // END LOAD PRODUCTS DESCRIPTION FROM SOURCE DB
-
- // ##########
-
- // LOAD PRODUCTS TO CATEGORIES FROM SOURCE DB
-
- $map = $this->_data_mapping['products_to_categs'];
-
- $products_to_categs = array();
-
- $sQry = $source_db->query('SELECT * FROM products_to_categories');
- $sQry->execute();
-
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $product = array(
- 'products_id' => $sQry->value('products_id')
- , 'categories_id' => $sQry->value('categories_id')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_products_to_categs (products_id,
- categories_id)
- VALUES (:products_id,
- :categories_id)');
-
- $tQry->bindTable(':table_products_to_categs', TABLE_PRODUCTS_TO_CATEGORIES);
- $tQry->bindInt (':products_id' , $product['products_id']);
- $tQry->bindInt (':categories_id', $product['categories_id']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $cnt++;
- }
-
- $sQry->freeResult();
- }
-
- // END LOAD PRODUCTS TO CATEGORIES FROM SOURCE DB
-
- // ##########
-
// LOAD PRODUCTS PERMALINK FROM SOURCE DB
$map = $this->_data_mapping['permalink'];
- $permalink_array = array();
-
$sQry = $source_db->query('SELECT p.products_id, language_id, products_name, categories_id FROM products as p, products_description AS pd, products_to_categories p2c WHERE p.products_id = pd.products_id AND p.products_id = p2c.products_id ORDER BY p.products_id, pd.language_id');
$sQry->execute();
+
+ // END LOAD PRODUCTS PERMALINK FROM SOURCE DB
+
+ // LOAD PERMALINK TO TARGET DB
if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
$cID = $sQry->value('categories_id') ;
- // getCPATH CODE
+ // getCPATH CODE
$cat_list = $cID;
$catID = $cID;
@@ -1444,336 +1431,275 @@ public function importProducts($switch = null) {
$sQry->freeResult();
}
-
- // END LOAD PRODUCTS PERMALINK FROM SOURCE DB
// END LOAD PERMALINK TO TARGET DB
-
- // ##########
- // LOAD MANUFACTURERS FROM SOURCE DB
- $map = $this->_data_mapping['manufacturers'];
-
- $manufacturers = array();
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
+
+ $source_db->disconnect();
+ $target_db->disconnect();
- $sQry = $source_db->query('select * from manufacturers');
- $sQry->execute();
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $manufacturer = array(
- 'manufacturers_id' => $sQry->value($map['manufacturers_id'])
- , 'manufacturers_name' => $sQry->value($map['manufacturers_name'])
- , 'manufacturers_image' => $sQry->value($map['manufacturers_image'])
- , 'date_added' => $sQry->value($map['date_added'])
- , 'last_modified' => $sQry->value($map['last_modified'])
- );
+ } // end importProductsDescription
- $tQry = $target_db->query('INSERT INTO :table_manufacturers (manufacturers_id,
- manufacturers_name,
- manufacturers_image,
- date_added,
- last_modified)
- VALUES (:manufacturers_id,
- :manufacturers_name,
- :manufacturers_image,
- :date_added,
- :last_modified)');
+ /*
+ * function name : importProductsNotifications()
+ *
+ * description : load products_notifications from the source database to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importProductsNotifications($switch = null) {
- $tQry->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
- $tQry->bindInt (':manufacturers_id' , $manufacturer['manufacturers_id']);
- $tQry->bindValue(':manufacturers_name' , $manufacturer['manufacturers_name']);
- $tQry->bindValue(':manufacturers_image', $manufacturer['manufacturers_image']);
- $tQry->bindDate (':date_added' , $manufacturer['date_added']);
- $tQry->bindDate (':last_modified' , $manufacturer['last_modified']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
- $cnt++;
- }
-
- $sQry->freeResult();
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
}
- // END LOAD MANUFACTURERS FROM SOURCE DB
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
- // #############
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
- // LOAD MANUFACTURERS INFO FROM SOURCE DB
- $map = $this->_data_mapping['manufacturers_info'];
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE PRODUCTS NOTIFICATIONS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_NOTIFICATIONS);
+ $tQry->execute();
- $manufacturers_infos = array();
+ // END TRUNCATE PRODUCTS NOTIFICATIONS TABLE IN TARGET DB
- $sQry = $source_db->query('SELECT * FROM manufacturers_info');
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD PRODUCTS NOTIFICATIONS FROM SOURCE DB
+
+ $map = $this->_data_mapping['products_notif'];
+
+ $sQry = $source_db->query('SELECT * FROM products_notifications');
$sQry->execute();
if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
- $manufacturers_info = array(
- 'manufacturers_id' => $sQry->value($map['manufacturers_id'])
- , 'languages_id' => $sQry->value($map['languages_id'])
- , 'manufacturers_url' => $sQry->value($map['manufacturers_url'])
- , 'url_clicked' => $sQry->value($map['url_clicked'])
- , 'date_last_click' => $sQry->value($map['date_last_click'])
- );
-
- $manufacturers_infos[] = $manufacturers_info;
+ $product = array(
+ 'products_id' => $sQry->value($map['products_id'])
+ , 'customers_id' => $sQry->value($map['customers_id'])
+ , 'date_added' => ($sQry->value($map['date_added']) != '' || $sQry->value($map['date_added']) != NULL) ? $sQry->value($map['date_added']) : ""
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_products_notifs (products_id,
+ customers_id,
+ date_added)
+ VALUES (:products_id,
+ :customers_id,
+ :date_added)');
+
+ $tQry->bindTable(':table_products_notifs', TABLE_PRODUCTS_NOTIFICATIONS);
+ $tQry->bindInt (':products_id' , $product['products_id']);
+ $tQry->bindInt (':customers_id' , $product['customers_id']);
+ $tQry->bindDate (':date_added' , $product['date_added']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
$cnt++;
}
$sQry->freeResult();
}
- // END LOAD MANUFACTURERS INFO FROM SOURCE DB
+ // END LOAD PRODUCTS DESCRIPTION FROM SOURCE DB
- // LOAD MANUFACTURERS INFO TO TARGET DB
-
- $iCnt = 0;
- foreach ($manufacturers_infos as $manufacturers_info) {
-
- $tQry = $target_db->query('INSERT INTO :table_manufacturers_info (manufacturers_id,
- languages_id,
- manufacturers_url,
- url_clicked,
- date_last_click)
- VALUES (:manufacturers_id,
- :languages_id,
- :manufacturers_url,
- :url_clicked,
- :date_last_click)');
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
+
+ $source_db->disconnect();
+ $target_db->disconnect();
- $tQry->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
- $tQry->bindInt (':manufacturers_id' , $manufacturers_info['manufacturers_id']);
- $tQry->bindInt (':languages_id' , $manufacturers_info['languages_id']);
- $tQry->bindValue(':manufacturers_url', $manufacturers_info['manufacturers_url']);
- $tQry->bindInt (':url_clicked' , $manufacturers_info['url_clicked']);
- $tQry->bindDate (':date_last_click' , $manufacturers_info['date_last_click']);
- $tQry->execute();
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
- $iCnt++;
- }
+ } // end importProductsNotifications
+
+ /*
+ * function name : importProductsToCategories()
+ *
+ * description : load products_to_categories, manufacturers, reviews and specials from the source database to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importProductsToCategories($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
- // END LOAD MANUFACTURERS INFO TO TARGET DB
+ // CONNNECT TO SOURCE DB
- // ##########
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
- // LOAD REVIEWS FROM SOURCE DB
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
- $map = $this->_data_mapping['reviews'];
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
- $reviews = array();
+ // END CONNNECT TO TARGET DB
- $sQry = $source_db->query('SELECT * FROM reviews r, reviews_description rd WHERE r.reviews_id = rd.reviews_id');
- $sQry->execute();
+ // TRUNCATE PRODUCTS TO CATEGORIES TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_TO_CATEGORIES);
+ $tQry->execute();
+
+ // END TRUNCATE PRODUCTS TO CATEGORIES TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD PRODUCTS TO CATEGORIES FROM SOURCE DB
+
+ $map = $this->_data_mapping['products_to_categs'];
+ $sQry = $source_db->query('SELECT * FROM products_to_categories');
+ $sQry->execute();
+
if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
- $review = array(
- 'reviews_id' => $sQry->value($map['reviews_id'])
- , 'products_id' => $sQry->value($map['products_id'])
- , 'customers_id' => $sQry->value($map['customers_id'])
- , 'customers_name' => $sQry->value($map['customers_name'])
- , 'reviews_rating' => $sQry->value($map['reviews_rating'])
- , 'languages_id' => $sQry->value($map['languages_id'])
- , 'reviews_text' => $sQry->value($map['reviews_text'])
- , 'date_added' => $sQry->value($map['date_added'])
- , 'last_modified' => $sQry->value($map['last_modified'])
- , 'reviews_read' => $sQry->value($map['reviews_read'])
- , 'reviews_status' => $sQry->value($map['reviews_status'])
- );
+ $product = array(
+ 'products_id' => $sQry->value('products_id')
+ , 'categories_id' => $sQry->value('categories_id')
+ );
- $reviews[] = $review;
+ $tQry = $target_db->query('INSERT INTO :table_products_to_categs (products_id,
+ categories_id)
+ VALUES (:products_id,
+ :categories_id)');
+
+ $tQry->bindTable(':table_products_to_categs', TABLE_PRODUCTS_TO_CATEGORIES);
+ $tQry->bindInt (':products_id' , $product['products_id']);
+ $tQry->bindInt (':categories_id' , $product['categories_id']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
$cnt++;
}
$sQry->freeResult();
}
- // END LOAD REVIEWS FROM SOURCE DB
+ // END LOAD PRODUCTS TO CATEGORIES FROM SOURCE DB
- // LOAD REVIEWS TO TARGET DB
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
- $iCnt = 0;
- foreach ($reviews as $review) {
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
- $tQry = $target_db->query('INSERT INTO :table_reviews (reviews_id,
- products_id,
- customers_id,
- customers_name,
- reviews_rating,
- languages_id,
- reviews_text,
- date_added,
- last_modified,
- reviews_read,
- reviews_status)
- VALUES (:reviews_id,
- :products_id,
- :customers_id,
- :customers_name,
- :reviews_rating,
- :languages_id,
- :reviews_text,
- :date_added,
- :last_modified,
- :reviews_read,
- :reviews_status)');
-
- $tQry->bindTable(':table_reviews', TABLE_REVIEWS);
- $tQry->bindInt (':reviews_id' , $review['reviews_id']);
- $tQry->bindInt (':products_id' , $review['products_id']);
- $tQry->bindInt (':customers_id' , $review['customers_id']);
- $tQry->bindValue(':customers_name', $review['customers_name']);
- $tQry->bindInt (':reviews_rating', $review['reviews_rating']);
- $tQry->bindInt (':languages_id' , $review['languages_id']);
- $tQry->bindValue(':reviews_text' , $review['reviews_text']);
- $tQry->bindDate (':date_added' , $review['date_added']);
- $tQry->bindDate (':last_modified' , $review['last_modified']);
- $tQry->bindInt (':reviews_read' , $review['reviews_read']);
- $tQry->bindInt (':reviews_status', 1);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $iCnt++;
- }
- $tQry->freeResult();
-
- // END LOAD REVIEWS FROM SOURCE DB
-
- // ##########
-
- // LOAD SPECIALS FROM SOURCE DB
-
- $map = $this->_data_mapping['specials'];
-
- $specials = array();
-
- $sQry = $source_db->query('SELECT * FROM specials');
- $sQry->execute();
-
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $special = array(
- 'specials_id' => $sQry->value($map['specials_id'])
- , 'products_id' => $sQry->value($map['products_id'])
- , 'specials_new_products_price' => $sQry->value($map['specials_new_products_price'])
- , 'specials_date_added' => $sQry->value($map['specials_date_added'])
- , 'specials_last_modified' => $sQry->value($map['specials_last_modified'])
- , 'start_date' => $sQry->value($map['start_date'])
- , 'expires_date' => $sQry->value($map['expires_date'])
- , 'date_status_change' => $sQry->value($map['date_status_change'])
- , 'status' => $sQry->value($map['status'])
- );
-
- $specials[] = $special;
- $cnt++;
- }
-
- $sQry->freeResult();
- }
-
- // END LOAD SPECIALS FROM SOURCE DB
-
- // LOAD SPECIALS TO TARGET DB
-
- $iCnt = 0;
- foreach ($specials as $special) {
-
- $tQry = $target_db->query('INSERT INTO :table_reviews (specials_id,
- products_id,
- specials_new_products_price,
- specials_date_added,
- specials_last_modified,
- start_date,
- expires_date,
- date_status_change,
- status)
- VALUES (:specials_id,
- :products_id,
- :specials_new_products_price,
- :specials_date_added,
- :specials_last_modified,
- :start_date, :expires_date,
- :date_status_change,
- :status)');
-
- $tQry->bindTable(':table_reviews', TABLE_SPECIALS);
- $tQry->bindInt (':specials_id' , $special['specials_id']);
- $tQry->bindInt (':products_id' , $special['products_id']);
- $tQry->bindInt (':specials_new_products_price', $special['specials_new_products_price']);
- $tQry->bindDate (':specials_date_added' , $special['specials_date_added']);
- $tQry->bindDate (':specials_last_modified' , $special['specials_last_modified']);
- $tQry->bindDate (':start_date' , $special['start_date']);
- $tQry->bindDate (':expires_date' , $special['expires_date']);
- $tQry->bindDate (':date_status_change' , $special['date_status_change']);
- $tQry->bindInt (':status' , $special['status']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $iCnt++;
- }
- $tQry->freeResult();
-
- // END LOAD SPECIALS FROM SOURCE DB
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
- $tQry->execute();
-
- // DISCONNECT FROM SOURCE AND TARGET DBs
-
- $source_db->disconnect();
-
- $target_db->disconnect();
-
- // END DISCONNECT FROM SOURCE AND TARGET DBs
-
- return true;
-
- } // end importProducts
+ } // end importProductsToCategories
/*
- * function name : getcPath()
+ * function name : importManufacturers()
*
- * description : get the recursive parent cPath of a category from the source db
+ * description : load manufacturers from the source database to loaded7
*
- * returns : string
+ * returns : true or false
*
*/
- public function getcPath($_cid, $_path = null) {
-
+ public function importManufacturers($switch = null) {
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
- $map = $this->_data_mapping['categories'];
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
- require_once('../includes/database_tables.php');
-
+ require_once('../includes/database_tables.php');
+
require_once('../includes/classes/database/mysqli.php');
- $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
if ($source_db->isError() === false) {
@@ -1786,51 +1712,118 @@ public function getcPath($_cid, $_path = null) {
}
// END CONNNECT TO SOURCE DB
- // BEGIN GET CPATH FOR CATEGORY
- $pQry = $source_db->query("SELECT DISTINCT (categories_id), parent_id FROM categories WHERE categories_id = " . $_cid);
- $pQry->execute();
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
- while ($pQry->next()) {
- if ($pQry->value('parent_id') != 0) {
- if ($_path != '') {
- $_path = $pQry->value('parent_id') . "_" . $_path;
- $path = lC_LocalUpgrader::getcPath($pQry->value('parent_id'), $_path) . "_" . $_path;
- } else {
- $path = $pQry->value('parent_id') . "_" . $_cid;
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE MANUFACTURERS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_MANUFACTURERS);
+ $tQry->execute();
+
+ // END TRUNCATE MANUFACTURERS TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD MANUFACTURERS FROM SOURCE DB
+ $map = $this->_data_mapping['manufacturers'];
+
+ $sQry = $source_db->query('select * from manufacturers');
+ $sQry->execute();
+
+ if ($sQry->numberOfRows() > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $manufacturer = array(
+ 'manufacturers_id' => $sQry->value($map['manufacturers_id'])
+ , 'manufacturers_name' => $sQry->value($map['manufacturers_name'])
+ , 'manufacturers_image' => $sQry->value($map['manufacturers_image'])
+ , 'date_added' => $sQry->value($map['date_added'])
+ , 'last_modified' => $sQry->value($map['last_modified'])
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_manufacturers (manufacturers_id,
+ manufacturers_name,
+ manufacturers_image,
+ date_added,
+ last_modified)
+ VALUES (:manufacturers_id,
+ :manufacturers_name,
+ :manufacturers_image,
+ :date_added,
+ :last_modified)');
+
+ $tQry->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
+ $tQry->bindInt (':manufacturers_id' , $manufacturer['manufacturers_id']);
+ $tQry->bindValue(':manufacturers_name' , $manufacturer['manufacturers_name']);
+ $tQry->bindValue(':manufacturers_image', $manufacturer['manufacturers_image']);
+ $tQry->bindDate (':date_added' , $manufacturer['date_added']);
+ $tQry->bindDate (':last_modified' , $manufacturer['last_modified']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
- } else {
- $path = $_cid;
+
+ $cnt++;
}
+
+ $sQry->freeResult();
}
+
+ // END LOAD MANUFACTURERS FROM SOURCE DB
- $pQry->freeResult();
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
- return $path;
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
- }
+ } // end importManufacturers
/*
- * function name : importCategories()
+ * function name : importManufacturersInfo()
*
- * description : load categories and categories_description to loaded7
+ * description : load manufacturers info from the source database to loaded7
*
* returns : true or false
*
*/
- public function importCategories($switch = null) {
-
+ public function importManufacturersInfo($switch = null) {
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
- $map = $this->_data_mapping['categories'];
-
+
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
- require_once('../includes/database_tables.php');
-
+ require_once('../includes/database_tables.php');
+
require_once('../includes/classes/database/mysqli.php');
- $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
if ($source_db->isError() === false) {
@@ -1843,8 +1836,8 @@ public function importCategories($switch = null) {
}
// END CONNNECT TO SOURCE DB
- // CONNNECT TO TARGET DB
-
+ // CONNNECT TO TARGET DB
+
$class = 'lC_Database_' . $t_db['DB_CLASS'];
$target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
@@ -1858,272 +1851,130 @@ public function importCategories($switch = null) {
}
// END CONNNECT TO TARGET DB
-
- // TRUNCATE CATEGORIES TABLES IN TARGET DB
-
- $tQry = $target_db->query('truncate table ' . TABLE_CATEGORIES);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_CATEGORIES_DESCRIPTION);
- $tQry->execute();
- $tQry = $target_db->query('truncate table ' . TABLE_PERMALINKS);
- $tQry->execute();
+ // TRUNCATE MANUFACTURERS INFO TABLE IN TARGET DB
- // END TRUNCATE CATEGORIES TABLES IN TARGET DB
+ $tQry = $target_db->query('truncate table ' . TABLE_MANUFACTURERS_INFO);
+ $tQry->execute();
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ // END TRUNCATE MANUFACTURERS INFO TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
- // LOAD CATEGORIES FROM SOURCE DB
-
- $sQry = $source_db->query('SELECT * FROM categories');
- $sQry->execute();
-
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $category = array(
- 'categories_id' => $sQry->value('categories_id')
- , 'categories_image' => $sQry->value('categories_image')
- , 'parent_id' => $sQry->value('parent_id')
- , 'sort_order' => $sQry->value('sort_order')
- , 'categories_mode' => 'category'
- , 'categories_link_target' => 0
- , 'categories_custom_url' => ""
- , 'categories_show_in_listings' => 1
- , 'categories_status' => 1
- , 'categories_visibility_nav' => 0
- , 'categories_visibility_box' => 1
- , 'date_added' => $sQry->value('date_added')
- , 'last_modified' => $sQry->value('last_modified')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_categories (categories_id,
- categories_image,
- parent_id,
- sort_order,
- categories_mode,
- categories_link_target,
- categories_custom_url,
- categories_status,
- categories_visibility_nav,
- categories_visibility_box,
- date_added,
- last_modified)
- VALUES (:categories_id,
- :categories_image,
- :parent_id,
- :sort_order,
- :categories_mode,
- :categories_link_target,
- :categories_custom_url,
- :categories_status,
- :categories_visibility_nav,
- :categories_visibility_box,
- :date_added,
- :last_modified)');
-
- $tQry->bindTable(':table_categories', TABLE_CATEGORIES);
- $tQry->bindInt (':categories_id' , $category['categories_id']);
- $tQry->bindValue(':categories_image' , $category['categories_image']);
- $tQry->bindInt (':parent_id' , $category['parent_id']);
- $tQry->bindInt (':sort_order' , $category['sort_order']);
- $tQry->bindValue(':categories_mode' , $category['categories_mode']);
- $tQry->bindInt (':categories_link_target' , $category['categories_link_target']);
- $tQry->bindValue(':categories_custom_url' , $category['categories_custom_url']);
- $tQry->bindInt (':categories_status' , $category['categories_status']);
- $tQry->bindInt (':categories_visibility_nav', $category['categories_visibility_nav']);
- $tQry->bindInt (':categories_visibility_box', $category['categories_visibility_box']);
- $tQry->bindDate (':date_added' , $category['date_added']);
- $tQry->bindDate (':last_modified' , $category['last_modified']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $cnt++;
- }
-
- $sQry->freeResult();
- }
-
- // END LOAD CATEGORIES FROM SOURCE DB
+ // LOAD MANUFACTURERS INFO FROM SOURCE DB
+ $map = $this->_data_mapping['manufacturers_info'];
- // ##########
-
- // LOAD CATEGORIES DESCRIPTION FROM SOURCE DB
+ $manufacturers_infos = array();
- $map = $this->_data_mapping['categories_desc'];
-
- $sQry = $source_db->query('SELECT * FROM categories_description');
+ $sQry = $source_db->query('SELECT * FROM manufacturers_info');
$sQry->execute();
-
- $categories_desc = array();
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
+ if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
-
- $c_ID = $sQry->value('categories_id');
-
- $c_keyword = self::generateCleanPermalink($sQry->value('categories_name'));
-
- if (preg_match('/category$/i', $c_keyword)) {
- $c_keyword .= '-link';
- }
-
- $category = array(
- 'categories_id' => $c_ID
- , 'language_id' => $sQry->value('language_id')
- , 'categories_name' => $sQry->value('categories_name')
- , 'categories_menu_name' => ""
- , 'categories_blurb' => ""
- , 'categories_description' => $sQry->value('categories_description')
- , 'categories_keyword' => $c_keyword
- , 'categories_tags' => $sQry->value('categories_head_keywords_tag')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
- language_id,
- categories_name,
- categories_menu_name,
- categories_blurb,
- categories_description,
- categories_keyword,
- categories_tags)
- VALUES (:categories_id,
- :language_id,
- :categories_name,
- :categories_menu_name,
- :categories_blurb,
- :categories_description,
- :categories_keyword,
- :categories_tags)');
-
- $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
- $tQry->bindInt (':categories_id' , $category['categories_id']);
- $tQry->bindInt (':language_id' , $category['language_id']);
- $tQry->bindValue(':categories_name' , $category['categories_name']);
- $tQry->bindValue(':categories_menu_name' , $category['categories_menu_name']);
- $tQry->bindValue(':categories_blurb' , $category['categories_blurb']);
- $tQry->bindValue(':categories_description', $category['categories_description']);
- $tQry->bindValue(':categories_keyword' , $category['categories_keyword']);
- $tQry->bindValue(':categories_tags' , substr($category['categories_tags'], 0, 255));
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
+ $manufacturers_info = array(
+ 'manufacturers_id' => $sQry->value($map['manufacturers_id'])
+ , 'languages_id' => $sQry->value($map['languages_id'])
+ , 'manufacturers_url' => $sQry->value($map['manufacturers_url'])
+ , 'url_clicked' => $sQry->value($map['url_clicked'])
+ , 'date_last_click' => $sQry->value($map['date_last_click'])
+ );
+
+ $manufacturers_infos[] = $manufacturers_info;
$cnt++;
}
$sQry->freeResult();
}
- // END LOAD CATEGORIES DESCRIPTION FROM SOURCE DB
-
- // ##########
+ // END LOAD MANUFACTURERS INFO FROM SOURCE DB
- // LOAD CATEGORY PERMALINKs TO TARGET DB
-
+ // LOAD MANUFACTURERS INFO TO TARGET DB
+
$iCnt = 0;
- $sQry = $source_db->query('SELECT c.categories_id, c.parent_id, cd.language_id, cd.categories_name FROM categories as c, categories_description AS cd WHERE c.categories_id = cd.categories_id');
- $sQry->execute();
+ foreach ($manufacturers_infos as $manufacturers_info) {
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
- while ($sQry->next()) {
-
- $c_ID = $sQry->value('categories_id');
+ $tQry = $target_db->query('INSERT INTO :table_manufacturers_info (manufacturers_id,
+ languages_id,
+ manufacturers_url,
+ url_clicked,
+ date_last_click)
+ VALUES (:manufacturers_id,
+ :languages_id,
+ :manufacturers_url,
+ :url_clicked,
+ :date_last_click)');
- // #### getCPATH CODE
-
- $cat_list = "cPath=" . lC_LocalUpgrader::getcPath($c_ID);
-
- // #### END getCPATH CODE
-
- $permatext = self::generateCleanPermalink($sQry->value('categories_name'));
+ $tQry->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
+ $tQry->bindInt (':manufacturers_id' , $manufacturers_info['manufacturers_id']);
+ $tQry->bindInt (':languages_id' , $manufacturers_info['languages_id']);
+ $tQry->bindValue(':manufacturers_url', $manufacturers_info['manufacturers_url']);
+ $tQry->bindInt (':url_clicked' , $manufacturers_info['url_clicked']);
+ $tQry->bindDate (':date_last_click' , $manufacturers_info['date_last_click']);
+ $tQry->execute();
- if (preg_match('/category$/i', $permatext)) {
- $permatext .= '-link';
- }
-
- $permalink = array(
- 'item_id' => $c_ID
- , 'language_id' => $sQry->value('language_id')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_permalink (item_id,
- language_id,
- `type`,
- query,
- permalink)
- VALUES (:item_id,
- :language_id,
- :type,
- :query,
- :permalink)');
-
- $tQry->bindTable(':table_permalink', TABLE_PERMALINKS);
- $tQry->bindInt (':item_id' , $permalink['item_id']);
- $tQry->bindInt (':language_id', $permalink['language_id']);
- $tQry->bindInt (':type' , 1);
- $tQry->bindValue(':query' , $cat_list);
- $tQry->bindValue(':permalink' , $permatext);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
- $iCnt++;
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
-
- $sQry->freeResult();
+ $iCnt++;
}
-
- // END LOAD PERMALINK TO TARGET DB
-
+
+ // END LOAD MANUFACTURERS INFO TO TARGET DB
+
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
$tQry->execute();
-
- $source_db->disconnect();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
+
+ $source_db->disconnect();
$target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
return true;
- } // end importCategories
+ } // end importManufacturersInfo
/*
- * function name : getcdsPath()
+ * function name : importReviews()
*
- * description : get the recursive parent CDpath of a cds category or page from the source db and convert it to cPath
+ * description : load reviews from the source database to loaded7
*
- * returns : string
+ * returns : true or false
*
*/
- public function getcdsPath($_cid, $_path) {
-
+ public function importReviews($switch = null) {
+
+ $s_db = $this->_sDB;
$t_db = $this->_tDB;
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
- // CONNNECT TO TARGET DB
-
- require_once('../includes/database_tables.php');
+ // CONNNECT TO SOURCE DB
+ require_once('../includes/database_tables.php');
+
require_once('../includes/classes/database/mysqli.php');
- $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
$target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
if ($target_db->isError() === false) {
@@ -2134,51 +1985,142 @@ public function getcdsPath($_cid, $_path) {
$this->_msg = $target_db->getError();
return false;
}
+
// END CONNNECT TO TARGET DB
- // BEGIN GET CPATH FOR CDS CATEGORY/PAGE
- $tQry = $target_db->query("SELECT DISTINCT (categories_id), parent_id FROM " . $t_db['DB_PREFIX'] . "categories WHERE categories_id = " . $_cid);
+ // TRUNCATE REVIEWS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_REVIEWS);
+ $tQry->execute();
+
+ // END TRUNCATE REVIEWS TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
- while ($tQry->next()) {
- if ($tQry->value('parent_id') != 0) {
- if ($_path != '') {
- $_path = $tQry->value('parent_id') . "_" . $_path;
- $path = lC_LocalUpgrader::getcdsPath($tQry->value('parent_id'), $_path) . "_" . $_path;
- } else {
- $path = $tQry->value('parent_id') . "_" . $_cid;
- }
- } else {
- $path = $_cid;
+ // LOAD REVIEWS FROM SOURCE DB
+
+ $map = $this->_data_mapping['reviews'];
+
+ $reviews = array();
+
+ $sQry = $source_db->query('SELECT * FROM reviews r, reviews_description rd WHERE r.reviews_id = rd.reviews_id');
+ $sQry->execute();
+
+ if ($sQry->numberOfRows() > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $review = array(
+ 'reviews_id' => $sQry->value($map['reviews_id'])
+ , 'products_id' => $sQry->value($map['products_id'])
+ , 'customers_id' => $sQry->value($map['customers_id'])
+ , 'customers_name' => $sQry->value($map['customers_name'])
+ , 'reviews_rating' => $sQry->value($map['reviews_rating'])
+ , 'languages_id' => $sQry->value($map['languages_id'])
+ , 'reviews_text' => $sQry->value($map['reviews_text'])
+ , 'date_added' => $sQry->value($map['date_added'])
+ , 'last_modified' => $sQry->value($map['last_modified'])
+ , 'reviews_read' => $sQry->value($map['reviews_read'])
+ , 'reviews_status' => $sQry->value($map['reviews_status'])
+ );
+
+ $reviews[] = $review;
+ $cnt++;
}
+
+ $sQry->freeResult();
}
+
+ // END LOAD REVIEWS FROM SOURCE DB
+
+ // LOAD REVIEWS TO TARGET DB
+
+ $iCnt = 0;
+ foreach ($reviews as $review) {
+
+ $tQry = $target_db->query('INSERT INTO :table_reviews (reviews_id,
+ products_id,
+ customers_id,
+ customers_name,
+ reviews_rating,
+ languages_id,
+ reviews_text,
+ date_added,
+ last_modified,
+ reviews_read,
+ reviews_status)
+ VALUES (:reviews_id,
+ :products_id,
+ :customers_id,
+ :customers_name,
+ :reviews_rating,
+ :languages_id,
+ :reviews_text,
+ :date_added,
+ :last_modified,
+ :reviews_read,
+ :reviews_status)');
+ $tQry->bindTable(':table_reviews', TABLE_REVIEWS);
+ $tQry->bindInt (':reviews_id' , $review['reviews_id']);
+ $tQry->bindInt (':products_id' , $review['products_id']);
+ $tQry->bindInt (':customers_id' , $review['customers_id']);
+ $tQry->bindValue(':customers_name', $review['customers_name']);
+ $tQry->bindInt (':reviews_rating', $review['reviews_rating']);
+ $tQry->bindInt (':languages_id' , $review['languages_id']);
+ $tQry->bindValue(':reviews_text' , $review['reviews_text']);
+ $tQry->bindDate (':date_added' , $review['date_added']);
+ $tQry->bindDate (':last_modified' , $review['last_modified']);
+ $tQry->bindInt (':reviews_read' , $review['reviews_read']);
+ $tQry->bindInt (':reviews_status', 1);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $iCnt++;
+ }
$tQry->freeResult();
+
+ // END LOAD REVIEWS FROM SOURCE DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // DISCONNECT FROM SOURCE AND TARGET DBs
- return $path;
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
- }
-
+ } // end importReviews
+
/*
- * function name : importPages()
+ * function name : importSpecials()
*
- * description : load pages and pages categories to loaded7
+ * description : load specials from the source database to loaded7
*
* returns : true or false
*
*/
- public function importPages($switch = null) {
-
+ public function importSpecials($switch = null) {
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
- $map = $this->_data_mapping['page_categories'];
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
- require_once('../includes/database_tables.php');
-
+ require_once('../includes/database_tables.php');
+
require_once('../includes/classes/database/mysqli.php');
$class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
@@ -2194,7 +2136,7 @@ public function importPages($switch = null) {
// END CONNNECT TO SOURCE DB
// CONNNECT TO TARGET DB
-
+
$class = 'lC_Database_' . $t_db['DB_CLASS'];
$target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
@@ -2208,58 +2150,257 @@ public function importPages($switch = null) {
}
// END CONNNECT TO TARGET DB
+
+ // TRUNCATE SPECIALS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_SPECIALS);
+ $tQry->execute();
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ // END TRUNCATE SPECIALS TABLE IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
+
+ // LOAD SPECIALS FROM SOURCE DB
+
+ $map = $this->_data_mapping['specials'];
- // END LOAD CATEGORY PAGES FROM SOURCE DB
-
- $page_categories = array();
-
- $sQry = $source_db->query('SELECT * FROM pages_categories');
+ $specials = array();
+
+ $sQry = $source_db->query('SELECT * FROM specials');
$sQry->execute();
-
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
+
+ if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
+ $special = array(
+ 'specials_id' => $sQry->value($map['specials_id'])
+ , 'products_id' => $sQry->value($map['products_id'])
+ , 'specials_new_products_price' => $sQry->value($map['specials_new_products_price'])
+ , 'specials_date_added' => $sQry->value($map['specials_date_added'])
+ , 'specials_last_modified' => $sQry->value($map['specials_last_modified'])
+ , 'start_date' => $sQry->value($map['start_date'])
+ , 'expires_date' => $sQry->value($map['expires_date'])
+ , 'date_status_change' => $sQry->value($map['date_status_change'])
+ , 'status' => $sQry->value($map['status'])
+ );
+
+ $specials[] = $special;
+ $cnt++;
+ }
- $cID = $sQry->value('categories_id');
+ $sQry->freeResult();
+ }
+
+ // END LOAD SPECIALS FROM SOURCE DB
+
+ // LOAD SPECIALS TO TARGET DB
+
+ $iCnt = 0;
+ foreach ($specials as $special) {
+
+ $tQry = $target_db->query('INSERT INTO :table_reviews (specials_id,
+ products_id,
+ specials_new_products_price,
+ specials_date_added,
+ specials_last_modified,
+ start_date,
+ expires_date,
+ date_status_change,
+ status)
+ VALUES (:specials_id,
+ :products_id,
+ :specials_new_products_price,
+ :specials_date_added,
+ :specials_last_modified,
+ :start_date, :expires_date,
+ :date_status_change,
+ :status)');
- $c_mode = 'category';
-
- $c_keyword = self::generateCleanPermalink($sQry->value($map['categories_name']));
+ $tQry->bindTable(':table_reviews', TABLE_SPECIALS);
+ $tQry->bindInt (':specials_id' , $special['specials_id']);
+ $tQry->bindInt (':products_id' , $special['products_id']);
+ $tQry->bindInt (':specials_new_products_price', $special['specials_new_products_price']);
+ $tQry->bindDate (':specials_date_added' , $special['specials_date_added']);
+ $tQry->bindDate (':specials_last_modified' , $special['specials_last_modified']);
+ $tQry->bindDate (':start_date' , $special['start_date']);
+ $tQry->bindDate (':expires_date' , $special['expires_date']);
+ $tQry->bindDate (':date_status_change' , $special['date_status_change']);
+ $tQry->bindInt (':status' , $special['status']);
+ $tQry->execute();
- if (preg_match('/category$/i', $c_keyword)) {
- $c_keyword .= '-link';
- }
-
- // added for category custom url (6.5 url override, only for external links and links to products)
- if ($sQry->value('categories_url_override') != '') {
- $c_mode = 'override';
- $c_override = 'index.php?old_urloverride=' . $sQry->value('categories_url_override');
- }
-
- $category = array(
- 'categories_id' => $cID
- , 'categories_image' => $sQry->value('categories_image')
- , 'parent_id' => $sQry->value('categories_parent_id')
- , 'sort_order' => $sQry->value('categories_sort_order')
- , 'categories_mode' => $c_mode
- , 'categories_link_target' => ($sQry->value('categories_url_override_target') != '') ? 1 : 0
- , 'categories_custom_url' => $c_override
- , 'categories_status' => $sQry->value('categories_status')
- , 'categories_visibility_nav' => 0
- , 'categories_visibility_box' => $sQry->value('categories_in_menu')
- , 'date_added' => $sQry->value('categories_date_added')
- , 'last_modified' => $sQry->value('categories_last_modified')
- );
-
- $c_mode = null;
- $c_override = null;
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $iCnt++;
+ }
+ $tQry->freeResult();
+
+ // END LOAD SPECIALS FROM SOURCE DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
- $tQry = $target_db->query('INSERT INTO :table_categories (categories_image,
+ // DISCONNECT FROM SOURCE AND TARGET DBs
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ // END DISCONNECT FROM SOURCE AND TARGET DBs
+
+ return true;
+
+ } // end importSpecials
+
+ /*
+ * function name : getcPath()
+ *
+ * description : get the recursive parent cPath of a category from the source db
+ *
+ * returns : string
+ *
+ */
+ public function getcPath($_cid, $_path = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+ $map = $this->_data_mapping['categories'];
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // BEGIN GET CPATH FOR CATEGORY
+ $pQry = $source_db->query("SELECT DISTINCT (categories_id), parent_id FROM categories WHERE categories_id = " . $_cid);
+ $pQry->execute();
+
+ while ($pQry->next()) {
+ if ($pQry->value('parent_id') != 0) {
+ if ($_path != '') {
+ $_path = $pQry->value('parent_id') . "_" . $_path;
+ $path = lC_LocalUpgrader::getcPath($pQry->value('parent_id'), $_path) . "_" . $_path;
+ } else {
+ $path = $pQry->value('parent_id') . "_" . $_cid;
+ }
+ } else {
+ $path = $_cid;
+ }
+ }
+
+ $pQry->freeResult();
+
+ return $path;
+
+ }
+
+ /*
+ * function name : importCategories()
+ *
+ * description : load categories to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importCategories($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+ $map = $this->_data_mapping['categories'];
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE CATEGORIES TABLES IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_CATEGORIES);
+ $tQry->execute();
+
+ // END TRUNCATE CATEGORIES TABLES IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD CATEGORIES FROM SOURCE DB
+
+ $sQry = $source_db->query('SELECT * FROM categories');
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $category = array(
+ 'categories_id' => $sQry->value('categories_id')
+ , 'categories_image' => $sQry->value('categories_image')
+ , 'parent_id' => $sQry->value('parent_id')
+ , 'sort_order' => $sQry->value('sort_order')
+ , 'categories_mode' => 'category'
+ , 'categories_link_target' => 0
+ , 'categories_custom_url' => ""
+ , 'categories_show_in_listings' => 1
+ , 'categories_status' => 1
+ , 'categories_visibility_nav' => 0
+ , 'categories_visibility_box' => 1
+ , 'date_added' => $sQry->value('date_added')
+ , 'last_modified' => $sQry->value('last_modified')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_categories (categories_id,
+ categories_image,
parent_id,
sort_order,
categories_mode,
@@ -2270,7 +2411,8 @@ public function importPages($switch = null) {
categories_visibility_box,
date_added,
last_modified)
- VALUES (:categories_image,
+ VALUES (:categories_id,
+ :categories_image,
:parent_id,
:sort_order,
:categories_mode,
@@ -2281,8 +2423,9 @@ public function importPages($switch = null) {
:categories_visibility_box,
:date_added,
:last_modified)');
-
+
$tQry->bindTable(':table_categories', TABLE_CATEGORIES);
+ $tQry->bindInt (':categories_id' , $category['categories_id']);
$tQry->bindValue(':categories_image' , $category['categories_image']);
$tQry->bindInt (':parent_id' , $category['parent_id']);
$tQry->bindInt (':sort_order' , $category['sort_order']);
@@ -2301,348 +2444,312 @@ public function importPages($switch = null) {
return false;
}
- $insert_id = $target_db->nextID();
- $page_categories[$cID] = $insert_id;
-
+ $cnt++;
}
$sQry->freeResult();
}
- // END LOAD CATEGORY PAGES FROM SOURCE DB
-
- // LOAD CATEGORY PAGES DESCRIPTION TO TARGET DB
+ // END LOAD CATEGORIES FROM SOURCE DB
- foreach ($page_categories as $cID => $insert_id) {
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry->execute();
- $sQry = $source_db->query('SELECT * FROM pages_categories_description pcd WHERE pcd.categories_id = ' . $cID);
- $sQry->execute();
-
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $c_keyword = self::generateCleanPermalink($sQry->value('categories_name'));
-
- if (preg_match('/category$/i', $c_keyword)) {
- $c_keyword .= '-link';
- }
-
- $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
- language_id,
- categories_name,
- categories_menu_name,
- categories_blurb,
- categories_description,
- categories_keyword,
- categories_tags)
- VALUES (:categories_id,
- :language_id,
- :categories_name,
- :categories_menu_name,
- :categories_blurb,
- :categories_description,
- :categories_keyword,
- :categories_tags)');
-
- $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
- $tQry->bindInt (':categories_id' , $insert_id);
- $tQry->bindInt (':language_id' , $sQry->value('language_id'));
- $tQry->bindValue(':categories_name' , $sQry->value('categories_name'));
- $tQry->bindValue(':categories_menu_name' , $sQry->value('categories_menu_name'));
- $tQry->bindValue(':categories_blurb' , $sQry->value('categories_blurb'));
- $tQry->bindValue(':categories_description', $sQry->value('categories_description'));
- $tQry->bindValue(':categories_keyword' , $c_keyword);
- $tQry->bindValue(':categories_tags' , $sQry->value('categories_meta_description'));
- $tQry->execute();
- }
- }
-
- $sQry->freeResult();
- }
+ $source_db->disconnect();
+ $target_db->disconnect();
- // END LOAD CATEGORY PAGES DESCRIPTION TO TARGET DB
+ return true;
+
+ } // end importCategories
+
+ /*
+ * function name : importCategoriesDescription()
+ *
+ * description : load categories_description & categories permalinks to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importCategoriesDescription($switch = null) {
- // LOAD PAGE PAGES FROM SOURCE DB
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+ $map = $this->_data_mapping['categories'];
- $map = $this->_data_mapping['page_pages'];
-
- $page_pages = array();
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
- $sQry = $source_db->query('SELECT * FROM pages AS p, pages_to_categories AS pc WHERE p.pages_id = pc.pages_id');
- $sQry->execute();
-
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE CATEGORIES DESCRIPTION & PERMALINKS TABLES IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_CATEGORIES_DESCRIPTION);
+ $tQry->execute();
+
+ $tQry = $target_db->query('truncate table ' . TABLE_PERMALINKS);
+ $tQry->execute();
+
+ // END TRUNCATE CATEGORIES DESCRIPTION & PERMALINKS TABLES IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD CATEGORIES DESCRIPTION FROM SOURCE DB
+
+ $map = $this->_data_mapping['categories_desc'];
+
+ $sQry = $source_db->query('SELECT * FROM categories_description');
+ $sQry->execute();
+
+ $categories_desc = array();
+
$numrows = $sQry->numberOfRows();
if ($numrows > 0) {
+ $cnt = 0;
while ($sQry->next()) {
- $pID = $sQry->value('pages_id');
-
- // get the original parent id from source db
- $cidQry = $source_db->query("SELECT categories_id FROM pages_to_categories WHERE pages_id = " . $sQry->value('pages_id'));
- $cidQry->execute();
-
- if ($cidQry->value('categories_id') != 0) {
- // get the original parent name from the source db
- $cnQry = $source_db->query("SELECT categories_name FROM pages_categories_description WHERE categories_id = " . $cidQry->value('categories_id'));
- $cnQry->execute();
-
- // get the new categories id from the target db
- $cnQry = $target_db->query("SELECT categories_id FROM " . $t_db['DB_PREFIX'] . "categories_description WHERE categories_name = '" . $cnQry->value('categories_name') . "'");
- $cnQry->execute();
-
- $cID = $cnQry->value('categories_id');
- } else {
- $cID = 0;
- }
-
- $c_keyword = self::generateCleanPermalink($sQry->value('pages_title'));
+
+ $c_ID = $sQry->value('categories_id');
+
+ $c_keyword = self::generateCleanPermalink($sQry->value('categories_name'));
if (preg_match('/category$/i', $c_keyword)) {
$c_keyword .= '-link';
}
- $page = array(
- 'categories_id' => $sQry->value('pages_id')
- , 'categories_image' => $sQry->value('pages_image')
- , 'parent_id' => $cID
- , 'sort_order' => $sQry->value('pages_sort_order')
- , 'categories_mode' => 'page'
- , 'categories_link_target' => 0
- , 'categories_custom_url' => ""
- , 'categories_status' => $sQry->value('pages_status')
- , 'categories_visibility_nav' => 0
- , 'categories_visibility_box' => $sQry->value('pages_in_menu')
- , 'date_added' => $sQry->value('pages_date_added')
- , 'last_modified' => $sQry->value('pages_last_modified')
- );
+ $category = array(
+ 'categories_id' => $c_ID
+ , 'language_id' => $sQry->value('language_id')
+ , 'categories_name' => $sQry->value('categories_name')
+ , 'categories_menu_name' => ""
+ , 'categories_blurb' => ""
+ , 'categories_description' => $sQry->value('categories_description')
+ , 'categories_keyword' => $c_keyword
+ , 'categories_tags' => $sQry->value('categories_head_keywords_tag')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
+ language_id,
+ categories_name,
+ categories_menu_name,
+ categories_blurb,
+ categories_description,
+ categories_keyword,
+ categories_tags)
+ VALUES (:categories_id,
+ :language_id,
+ :categories_name,
+ :categories_menu_name,
+ :categories_blurb,
+ :categories_description,
+ :categories_keyword,
+ :categories_tags)');
- $tQry = $target_db->query('INSERT INTO :table_categories (categories_image,
- parent_id,
- sort_order,
- categories_mode,
- categories_link_target,
- categories_custom_url,
- categories_status,
- categories_visibility_nav,
- categories_visibility_box,
- date_added,
- last_modified)
- VALUES (:categories_image,
- :parent_id,
- :sort_order,
- :categories_mode,
- :categories_link_target,
- :categories_custom_url,
- :categories_status,
- :categories_visibility_nav,
- :categories_visibility_box,
- :date_added,
- :last_modified)');
-
- $tQry->bindTable(':table_categories', TABLE_CATEGORIES);
- $tQry->bindValue(':categories_image' , $page['categories_image']);
- $tQry->bindInt (':parent_id' , $page['parent_id']);
- $tQry->bindInt (':sort_order' , $page['sort_order']);
- $tQry->bindValue(':categories_mode' , $page['categories_mode']);
- $tQry->bindInt (':categories_link_target' , $page['categories_link_target']);
- $tQry->bindValue(':categories_custom_url' , $page['categories_custom_url']);
- $tQry->bindInt (':categories_status' , $page['categories_status']);
- $tQry->bindInt (':categories_visibility_nav', $page['categories_visibility_nav']);
- $tQry->bindInt (':categories_visibility_box', $page['categories_visibility_box']);
- $tQry->bindDate (':date_added' , $page['date_added']);
- $tQry->bindDate (':last_modified' , $page['last_modified']);
+ $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
+ $tQry->bindInt (':categories_id' , $category['categories_id']);
+ $tQry->bindInt (':language_id' , $category['language_id']);
+ $tQry->bindValue(':categories_name' , $category['categories_name']);
+ $tQry->bindValue(':categories_menu_name' , $category['categories_menu_name']);
+ $tQry->bindValue(':categories_blurb' , $category['categories_blurb']);
+ $tQry->bindValue(':categories_description', $category['categories_description']);
+ $tQry->bindValue(':categories_keyword' , $category['categories_keyword']);
+ $tQry->bindValue(':categories_tags' , substr($category['categories_tags'], 0, 255));
$tQry->execute();
- $insert_id = $target_db->nextID();
- $page_pages[$pID] = $insert_id;
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $cnt++;
}
$sQry->freeResult();
}
- // END LOAD PAGE PAGES FROM SOURCE DB
+ // END LOAD CATEGORIES DESCRIPTION FROM SOURCE DB
- // LOAD PAGE PAGES DESCRIPTION TO TARGET DB
+ // ##########
+
+ // LOAD CATEGORIES PERMALINKS TO TARGET DB
- foreach ($page_pages as $pID => $insert_id) {
+ $iCnt = 0;
+ $sQry = $source_db->query('SELECT c.categories_id, c.parent_id, cd.language_id, cd.categories_name FROM categories as c, categories_description AS cd WHERE c.categories_id = cd.categories_id');
+ $sQry->execute();
- $sQry = $source_db->query('SELECT * FROM pages_description WHERE pages_id = ' . $pID);
- $sQry->execute();
-
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
- while ($sQry->next()) {
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ while ($sQry->next()) {
- $c_keyword = self::generateCleanPermalink($sQry->value('pages_title'));
-
- if (preg_match('/category$/i', $c_keyword)) {
- $c_keyword .= '-link';
- }
-
- $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
- language_id,
- categories_name,
- categories_menu_name,
- categories_blurb,
- categories_description,
- categories_keyword,
- categories_tags)
- VALUES (:categories_id,
- :language_id,
- :categories_name,
- :categories_menu_name,
- :categories_blurb,
- :categories_description,
- :categories_keyword,
- :categories_tags)');
-
- $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
- $tQry->bindInt (':categories_id' , $insert_id);
- $tQry->bindInt (':language_id' , $sQry->value('language_id') );
- $tQry->bindValue(':categories_name' , $sQry->value('pages_title') );
- $tQry->bindValue(':categories_menu_name' , $sQry->value('pages_menu_name') );
- $tQry->bindValue(':categories_blurb' , $sQry->value('pages_blurb') );
- $tQry->bindValue(':categories_description', $sQry->value('pages_body') );
- $tQry->bindValue(':categories_keyword' , $c_keyword);
- $tQry->bindValue(':categories_tags' , $sQry->value('pages_meta_keywords') );
- $tQry->execute();
- }
- }
- }
-
- // END LOAD PAGE PAGES DESCRIPTION TO TARGET DB
-
- // LOAD CATEGORY PAGES PERMALINK FROM TARGET DB
+ $c_ID = $sQry->value('categories_id');
- $permalink_array = array();
-
- foreach ($page_categories as $cID => $insert_id) {
- $tQry = $target_db->query("SELECT c.categories_id, cd.language_id, cd.categories_keyword FROM " . $t_db['DB_PREFIX'] . "categories AS c, " . $t_db['DB_PREFIX'] . "categories_description AS cd WHERE c.categories_id = " . $insert_id . " AND c.categories_id = cd.categories_id");
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
+ // #### getCPATH CODE
+
+ $cat_list = "cPath=" . lC_LocalUpgrader::getcPath($c_ID);
+
+ // #### END getCPATH CODE
+
+ $permatext = self::generateCleanPermalink($sQry->value('categories_name'));
- if ($tQry->numberOfRows() > 0) {
- while ($tQry->next()) {
- $permalink = array(
- 'item_id' => $tQry->value('categories_id')
- , 'language_id' => $tQry->value('language_id')
- , 'type' => 1
- , 'query' => ''
- , 'permalink' => $tQry->value('categories_keyword')
- );
-
- $permalink_array[] = $permalink;
+ if (preg_match('/category$/i', $permatext)) {
+ $permatext .= '-link';
+ }
+
+ $permalink = array(
+ 'item_id' => $c_ID
+ , 'language_id' => $sQry->value('language_id')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_permalink (item_id,
+ language_id,
+ `type`,
+ query,
+ permalink)
+ VALUES (:item_id,
+ :language_id,
+ :type,
+ :query,
+ :permalink)');
+
+ $tQry->bindTable(':table_permalink', TABLE_PERMALINKS);
+ $tQry->bindInt (':item_id' , $permalink['item_id']);
+ $tQry->bindInt (':language_id', $permalink['language_id']);
+ $tQry->bindInt (':type' , 1);
+ $tQry->bindValue(':query' , $cat_list);
+ $tQry->bindValue(':permalink' , $permatext);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
+
+ $iCnt++;
}
+
+ $sQry->freeResult();
}
- // END LOAD CATEGORY PAGES PERMALINK FROM SOURCE DB
+ // END LOAD CATEGORIES PERMALINKS TO TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry->execute();
- // LOAD PAGES PAGES PERMALINK FROM TARGET DB
+ $source_db->disconnect();
+ $target_db->disconnect();
- foreach ($page_pages as $cID => $insert_id) {
- $tQry = $target_db->query("SELECT c.categories_id, cd.language_id, cd.categories_keyword FROM " . $t_db['DB_PREFIX'] . "categories AS c, " . $t_db['DB_PREFIX'] . "categories_description AS cd WHERE c.categories_id = " . $insert_id . " AND c.categories_id = cd.categories_id");
- $tQry->execute();
+ return true;
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
+ } // end importCategories
+
+ /*
+ * function name : getcdsPath()
+ *
+ * description : get the recursive parent CDpath of a cds category or page from the source db and convert it to cPath
+ *
+ * returns : string
+ *
+ */
+ public function getcdsPath($_cid, $_path) {
- if ($tQry->numberOfRows() > 0) {
- while ($tQry->next()) {
- $permalink = array(
- 'item_id' => $tQry->value('categories_id')
- , 'language_id' => $tQry->value('language_id')
- , 'type' => 1
- , 'query' => ''
- , 'permalink' => $tQry->value('categories_keyword')
- );
- $permalink_array[] = $permalink;
- }
- }
- $tQry->freeResult();
- }
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
- // END LOAD PAGES PAGES PERMALINK FROM SOURCE DB
+ // CONNNECT TO TARGET DB
- // SAVE CATEGORY PAGES AND PAGE PAGES PERMALINKS TO TARGET DB
-
- $iCnt = 0;
+ require_once('../includes/database_tables.php');
- foreach ($permalink_array as $permalink) {
-
- // #### getCPATH CODE
-
- $cat_list = "cPath=" . lC_LocalUpgrader::getcdsPath($permalink['item_id'], null);
-
- // #### END getCPATH CODE
-
- $tQry = $target_db->query('INSERT INTO :table_permalink (item_id,
- language_id,
- `type`,
- query,
- permalink)
- VALUES (:item_id,
- :language_id,
- :type,
- :query,
- :permalink)');
-
- $tQry->bindTable(':table_permalink', TABLE_PERMALINKS);
- $tQry->bindInt (':item_id' , $permalink['item_id']);
- $tQry->bindInt (':language_id', $permalink['language_id']);
- $tQry->bindInt (':type' , $permalink['type']);
- $tQry->bindValue(':query' , $cat_list);
- $tQry->bindValue(':permalink' , self::generateCleanPermalink($permalink['permalink']));
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
-
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
}
- $tQry->freeResult();
-
- // END LOAD PERMALINK TO TARGET DB
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+ // END CONNNECT TO TARGET DB
+
+ // BEGIN GET CPATH FOR CDS CATEGORY/PAGE
+ $tQry = $target_db->query("SELECT DISTINCT (categories_id), parent_id FROM " . $t_db['DB_PREFIX'] . "categories WHERE categories_id = " . $_cid);
$tQry->execute();
+
+ while ($tQry->next()) {
+ if ($tQry->value('parent_id') != 0) {
+ if ($_path != '') {
+ $_path = $tQry->value('parent_id') . "_" . $_path;
+ $path = lC_LocalUpgrader::getcdsPath($tQry->value('parent_id'), $_path) . "_" . $_path;
+ } else {
+ $path = $tQry->value('parent_id') . "_" . $_cid;
+ }
+ } else {
+ $path = $_cid;
+ }
+ }
- $source_db->disconnect();
- $target_db->disconnect();
+ $tQry->freeResult();
- return true;
+ return $path;
- } // end importPages
+ }
/*
- * function name : importCustomers()
+ * function name : importPages()
*
- * description : load customers and address book data from the source database to loaded7
+ * description : load pages and pages categories to loaded7
*
* returns : true or false
*
*/
- public function importCustomers($switch = null) {
+ public function importPages($switch = null) {
$s_db = $this->_sDB;
$t_db = $this->_tDB;
- $map = $this->_data_mapping['customers'];
+ $map = $this->_data_mapping['page_categories'];
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
require_once('../includes/database_tables.php');
-
+
require_once('../includes/classes/database/mysqli.php');
$class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
@@ -2673,470 +2780,440 @@ public function importCustomers($switch = null) {
// END CONNNECT TO TARGET DB
- // TRUNCATE CUSTOMERS TABLES IN TARGET DB
-
- $tQry = $target_db->query('truncate table ' . TABLE_CUSTOMERS);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_ADDRESS_BOOK);
- $tQry->execute();
-
- // END TRUNCATE CUSTOMERS TABLES IN TARGET DB
-
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
- // LOAD CUSTOMERS FROM SOURCE DB
+ // END LOAD CATEGORY PAGES FROM SOURCE DB
- $sQry = $source_db->query('SELECT * FROM customers c LEFT JOIN customers_info ci ON c.customers_id = ci.customers_info_id');
+ $page_categories = array();
+
+ $sQry = $source_db->query('SELECT * FROM pages_categories');
$sQry->execute();
-
- $customers = array();
- if ($sQry->numberOfRows() > 0) {
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
$cnt = 0;
while ($sQry->next()) {
- $customer = array(
- 'customers_id' => $sQry->value($map['customers_id'])
- , 'customers_group_id' => ($sQry->value($map['customers_group_id']) != null) ? $sQry->value($map['customers_group_id']) : 1
- , 'customers_gender' => $sQry->value($map['customers_gender'])
- , 'customers_firstname' => $sQry->value($map['customers_firstname'])
- , 'customers_lastname' => $sQry->value($map['customers_lastname'])
- , 'customers_dob' => $sQry->value($map['customers_dob'])
- , 'customers_email_address' => $sQry->value($map['customers_email_address'])
- , 'customers_default_address_id' => $sQry->value($map['customers_default_address_id'])
- , 'customers_telephone' => ($sQry->value($map['customers_telephone']) != '' || $sQry->value($map['customers_telephone']) != NULL) ? $sQry->value($map['customers_telephone']) : ""
- , 'customers_fax' => ($sQry->value($map['customers_fax']) != '' || $sQry->value($map['customers_fax']) != NULL) ? $sQry->value($map['customers_fax']) : ""
- , 'customers_password' => $sQry->value($map['customers_password'])
- , 'customers_newsletter' => $sQry->value($map['customers_newsletter'])
- , 'customers_status' => 1
- , 'customers_ip_address' => ($sQry->value($map['customers_ip_address']) != '' || $sQry->value($map['customers_ip_address']) != NULL) ? $sQry->value($map['customers_ip_address']) : ""
- , 'date_last_logon' => ($sQry->value($map['date_last_logon']) != '' || $sQry->value($map['date_last_logon']) != NULL) ? $sQry->value($map['date_last_logon']) : ""
- , 'number_of_logons' => ($sQry->value($map['number_of_logons']) != '' || $sQry->value($map['number_of_logons']) != NULL) ? $sQry->value($map['number_of_logons']) : ""
- , 'date_account_created' => ($sQry->value($map['date_account_created']) != '' || $sQry->value($map['date_account_created']) != NULL) ? $sQry->value($map['date_account_created']) : ""
- , 'date_account_last_modified' => ($sQry->value($map['date_account_last_modified']) != '' || $sQry->value($map['date_account_last_modified']) != NULL) ? $sQry->value($map['date_account_last_modified']) : ""
- , 'global_product_notifications' => ($sQry->value($map['global_product_notifications']) != '' || $sQry->value($map['global_product_notifications']) != NULL) ? $sQry->value($map['global_product_notifications']) : 1
- );
-
- $tQry = $target_db->query('INSERT INTO :table_customers (customers_id,
- customers_group_id,
- customers_gender,
- customers_firstname,
- customers_lastname,
- customers_dob,
- customers_email_address,
- customers_default_address_id,
- customers_telephone,
- customers_fax,
- customers_password,
- customers_newsletter,
- customers_status,
- customers_ip_address,
- date_last_logon,
- number_of_logons,
- date_account_created,
- date_account_last_modified,
- global_product_notifications)
- VALUES (:customers_id,
- :customers_group_id,
- :customers_gender,
- :customers_firstname,
- :customers_lastname,
- :customers_dob,
- :customers_email_address,
- :customers_default_address_id,
- :customers_telephone,
- :customers_fax,
- :customers_password,
- :customers_newsletter,
- :customers_status,
- :customers_ip_address,
- :date_last_logon,
- :number_of_logons,
- :date_account_created,
- :date_account_last_modified,
- :global_product_notifications)');
+
+ $cID = $sQry->value('categories_id');
- $tQry->bindTable(':table_customers', TABLE_CUSTOMERS);
- $tQry->bindInt (':customers_id' , $customer['customers_id']);
- $tQry->bindInt (':customers_group_id' , $customer['customers_group_id']);
- $tQry->bindValue(':customers_gender' , $customer['customers_gender']);
- $tQry->bindValue(':customers_firstname' , $customer['customers_firstname']);
- $tQry->bindValue(':customers_lastname' , $customer['customers_lastname']);
- $tQry->bindDate (':customers_dob' , $customer['customers_dob']);
- $tQry->bindValue(':customers_email_address' , $customer['customers_email_address']);
- $tQry->bindInt (':customers_default_address_id', $customer['customers_default_address_id']);
- $tQry->bindValue(':customers_telephone' , $customer['customers_telephone']);
- $tQry->bindValue(':customers_fax' , $customer['customers_fax']);
- $tQry->bindValue(':customers_password' , $customer['customers_password']);
- $tQry->bindValue(':customers_newsletter' , $customer['customers_newsletter']);
- $tQry->bindInt (':customers_status' , $customer['customers_status']);
- $tQry->bindValue(':customers_ip_address' , $customer['customers_ip_address']);
- $tQry->bindDate (':date_last_logon' , $customer['date_last_logon']);
- $tQry->bindInt (':number_of_logons' , $customer['number_of_logons']);
- $tQry->bindDate (':date_account_created' , $customer['date_account_created']);
- $tQry->bindDate (':date_account_last_modified' , $customer['date_account_last_modified']);
- $tQry->bindInt (':global_product_notifications', $customer['global_product_notifications']);
+ $c_mode = 'category';
+
+ $c_keyword = self::generateCleanPermalink($sQry->value($map['categories_name']));
+
+ if (preg_match('/category$/i', $c_keyword)) {
+ $c_keyword .= '-link';
+ }
+
+ // added for category custom url (6.5 url override, only for external links and links to products)
+ if ($sQry->value('categories_url_override') != '') {
+ $c_mode = 'override';
+ $c_override = 'index.php?old_urloverride=' . $sQry->value('categories_url_override');
+ }
+
+ $category = array(
+ 'categories_id' => $cID
+ , 'categories_image' => $sQry->value('categories_image')
+ , 'parent_id' => $sQry->value('categories_parent_id')
+ , 'sort_order' => $sQry->value('categories_sort_order')
+ , 'categories_mode' => $c_mode
+ , 'categories_link_target' => ($sQry->value('categories_url_override_target') != '') ? 1 : 0
+ , 'categories_custom_url' => $c_override
+ , 'categories_status' => $sQry->value('categories_status')
+ , 'categories_visibility_nav' => 0
+ , 'categories_visibility_box' => $sQry->value('categories_in_menu')
+ , 'date_added' => $sQry->value('categories_date_added')
+ , 'last_modified' => $sQry->value('categories_last_modified')
+ );
+
+ $c_mode = null;
+ $c_override = null;
+
+ $tQry = $target_db->query('INSERT INTO :table_categories (categories_image,
+ parent_id,
+ sort_order,
+ categories_mode,
+ categories_link_target,
+ categories_custom_url,
+ categories_status,
+ categories_visibility_nav,
+ categories_visibility_box,
+ date_added,
+ last_modified)
+ VALUES (:categories_image,
+ :parent_id,
+ :sort_order,
+ :categories_mode,
+ :categories_link_target,
+ :categories_custom_url,
+ :categories_status,
+ :categories_visibility_nav,
+ :categories_visibility_box,
+ :date_added,
+ :last_modified)');
+
+ $tQry->bindTable(':table_categories', TABLE_CATEGORIES);
+ $tQry->bindValue(':categories_image' , $category['categories_image']);
+ $tQry->bindInt (':parent_id' , $category['parent_id']);
+ $tQry->bindInt (':sort_order' , $category['sort_order']);
+ $tQry->bindValue(':categories_mode' , $category['categories_mode']);
+ $tQry->bindInt (':categories_link_target' , $category['categories_link_target']);
+ $tQry->bindValue(':categories_custom_url' , $category['categories_custom_url']);
+ $tQry->bindInt (':categories_status' , $category['categories_status']);
+ $tQry->bindInt (':categories_visibility_nav', $category['categories_visibility_nav']);
+ $tQry->bindInt (':categories_visibility_box', $category['categories_visibility_box']);
+ $tQry->bindDate (':date_added' , $category['date_added']);
+ $tQry->bindDate (':last_modified' , $category['last_modified']);
$tQry->execute();
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
-
- $cnt++;
+
+ $insert_id = $target_db->nextID();
+ $page_categories[$cID] = $insert_id;
+
}
$sQry->freeResult();
}
- // END LOAD CUSTOMERS FROM SOURCE DB
+ // END LOAD CATEGORY PAGES FROM SOURCE DB
- // ##########
-
- // LOAD ADDRESS BOOK FROM SOURCE DB
+ // LOAD CATEGORY PAGES DESCRIPTION TO TARGET DB
- $map = $this->_data_mapping['address_book'];
+ foreach ($page_categories as $cID => $insert_id) {
- $sQry = $source_db->query('SELECT * FROM address_book');
- $sQry->execute();
-
- $customers = array();
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $address = array(
- 'address_book_id' => $sQry->value($map['address_book_id'])
- , 'customers_id' => $sQry->value($map['customers_id'])
- , 'entry_gender' => $sQry->value($map['entry_gender'])
- , 'entry_company' => $sQry->value($map['entry_company'])
- , 'entry_firstname' => $sQry->value($map['entry_firstname'])
- , 'entry_lastname' => $sQry->value($map['entry_lastname'])
- , 'entry_street_address' => $sQry->value($map['entry_street_address'])
- , 'entry_suburb' => $sQry->value($map['entry_suburb'])
- , 'entry_postcode' => $sQry->value($map['entry_postcode'])
- , 'entry_city' => $sQry->value($map['entry_city'])
- , 'entry_state' => $sQry->value($map['entry_state'])
- , 'entry_country_id' => $sQry->value($map['entry_country_id'])
- , 'entry_zone_id' => $sQry->value($map['entry_zone_id'])
- , 'entry_telephone' => $sQry->value($map['entry_telephone'])
- , 'entry_fax' => $sQry->value($map['entry_fax'])
- );
-
- // get zone_name from source db
- if ($sQry->value($map['entry_zone_id']) != 0) {
- $znQry = $source_db->query("SELECT zone_name FROM zones WHERE zone_id = " . $sQry->value($map['entry_zone_id']));
- $znQry->execute();
- $zone_name = $znQry->value('zone_name');
- } else {
- $zone_name = $sQry->value($map['entry_state']);
- }
-
- // get zone_code from new db
- $nzQry = $target_db->query("SELECT zone_id FROM " . $t_db['DB_PREFIX'] . "zones WHERE zone_country_id = " . $sQry->value($map['entry_country_id']) . " AND zone_name = '" . $zone_name . "'");
- $nzQry->execute();
-
- $tQry = $target_db->query('INSERT INTO :table_address_book (address_book_id,
- customers_id,
- entry_gender,
- entry_company,
- entry_firstname,
- entry_lastname,
- entry_street_address,
- entry_suburb,
- entry_postcode,
- entry_city,
- entry_state,
- entry_country_id,
- entry_zone_id,
- entry_telephone,
- entry_fax)
- VALUES (:address_book_id,
- :customers_id,
- :entry_gender,
- :entry_company,
- :entry_firstname,
- :entry_lastname,
- :entry_street_address,
- :entry_suburb,
- :entry_postcode,
- :entry_city,
- :entry_state,
- :entry_country_id,
- :entry_zone_id,
- :entry_telephone,
- :entry_fax)');
-
- $tQry->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
- $tQry->bindInt (':address_book_id' , $address['address_book_id']);
- $tQry->bindInt (':customers_id' , $address['customers_id']);
- $tQry->bindValue(':entry_gender' , $address['entry_gender']);
- $tQry->bindValue(':entry_company' , $address['entry_company']);
- $tQry->bindValue(':entry_firstname' , $address['entry_firstname']);
- $tQry->bindValue(':entry_lastname' , $address['entry_lastname']);
- $tQry->bindValue(':entry_street_address', $address['entry_street_address']);
- $tQry->bindValue(':entry_suburb' , $address['entry_suburb']);
- $tQry->bindValue(':entry_postcode' , $address['entry_postcode']);
- $tQry->bindValue(':entry_city' , $address['entry_city']);
- $tQry->bindValue(':entry_state' , $zone_name);
- $tQry->bindInt (':entry_country_id' , $address['entry_country_id']);
- $tQry->bindInt (':entry_zone_id' , $nzQry->value('zone_id'));
- $tQry->bindValue(':entry_telephone' , $address['entry_telephone']);
- $tQry->bindValue(':entry_fax' , $address['entry_fax']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
+ $sQry = $source_db->query('SELECT * FROM pages_categories_description pcd WHERE pcd.categories_id = ' . $cID);
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $c_keyword = self::generateCleanPermalink($sQry->value('categories_name'));
+
+ if (preg_match('/category$/i', $c_keyword)) {
+ $c_keyword .= '-link';
+ }
+
+ $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
+ language_id,
+ categories_name,
+ categories_menu_name,
+ categories_blurb,
+ categories_description,
+ categories_keyword,
+ categories_tags)
+ VALUES (:categories_id,
+ :language_id,
+ :categories_name,
+ :categories_menu_name,
+ :categories_blurb,
+ :categories_description,
+ :categories_keyword,
+ :categories_tags)');
+
+ $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
+ $tQry->bindInt (':categories_id' , $insert_id);
+ $tQry->bindInt (':language_id' , $sQry->value('language_id'));
+ $tQry->bindValue(':categories_name' , $sQry->value('categories_name'));
+ $tQry->bindValue(':categories_menu_name' , $sQry->value('categories_menu_name'));
+ $tQry->bindValue(':categories_blurb' , $sQry->value('categories_blurb'));
+ $tQry->bindValue(':categories_description', $sQry->value('categories_description'));
+ $tQry->bindValue(':categories_keyword' , $c_keyword);
+ $tQry->bindValue(':categories_tags' , $sQry->value('categories_meta_description'));
+ $tQry->execute();
}
-
- $cnt++;
}
$sQry->freeResult();
}
- // END LOAD ADDRESS BOOK FROM SOURCE DB
-
- // ##########
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
- $tQry->execute();
+ // END LOAD CATEGORY PAGES DESCRIPTION TO TARGET DB
- $source_db->disconnect();
- $target_db->disconnect();
+ // LOAD PAGE PAGES FROM SOURCE DB
- return true;
-
- } // end importCustomers
+ $map = $this->_data_mapping['page_pages'];
- /*
- * function name : importImages()
- *
- * description : load product images to loaded7
- *
- * returns : true or false
- *
- */
- public function importImages() {
- global $lC_Language;
-
- $source_img_dir = $this->_sDB['INSTALL_PATH'].$this->_sDB['IMAGE_PATH'];
- $target_img_dir = getcwd() . '/../images/products/originals/';
+ $page_pages = array();
- $s_db = $this->_sDB;
- $t_db = $this->_tDB;
+ $sQry = $source_db->query('SELECT * FROM pages AS p, pages_to_categories AS pc WHERE p.pages_id = pc.pages_id');
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ while ($sQry->next()) {
+ $pID = $sQry->value('pages_id');
+
+ // get the original parent id from source db
+ $cidQry = $source_db->query("SELECT categories_id FROM pages_to_categories WHERE pages_id = " . $sQry->value('pages_id'));
+ $cidQry->execute();
+
+ if ($cidQry->value('categories_id') != 0) {
+ // get the original parent name from the source db
+ $cnQry = $source_db->query("SELECT categories_name FROM pages_categories_description WHERE categories_id = " . $cidQry->value('categories_id'));
+ $cnQry->execute();
- if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
-
- // CONNNECT TO SOURCE DB
+ // get the new categories id from the target db
+ $cnQry = $target_db->query("SELECT categories_id FROM " . $t_db['DB_PREFIX'] . "categories_description WHERE categories_name = '" . $cnQry->value('categories_name') . "'");
+ $cnQry->execute();
+
+ $cID = $cnQry->value('categories_id');
+ } else {
+ $cID = 0;
+ }
+
+ $c_keyword = self::generateCleanPermalink($sQry->value('pages_title'));
+
+ if (preg_match('/category$/i', $c_keyword)) {
+ $c_keyword .= '-link';
+ }
+
+ $page = array(
+ 'categories_id' => $sQry->value('pages_id')
+ , 'categories_image' => $sQry->value('pages_image')
+ , 'parent_id' => $cID
+ , 'sort_order' => $sQry->value('pages_sort_order')
+ , 'categories_mode' => 'page'
+ , 'categories_link_target' => 0
+ , 'categories_custom_url' => ""
+ , 'categories_status' => $sQry->value('pages_status')
+ , 'categories_visibility_nav' => 0
+ , 'categories_visibility_box' => $sQry->value('pages_in_menu')
+ , 'date_added' => $sQry->value('pages_date_added')
+ , 'last_modified' => $sQry->value('pages_last_modified')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_categories (categories_image,
+ parent_id,
+ sort_order,
+ categories_mode,
+ categories_link_target,
+ categories_custom_url,
+ categories_status,
+ categories_visibility_nav,
+ categories_visibility_box,
+ date_added,
+ last_modified)
+ VALUES (:categories_image,
+ :parent_id,
+ :sort_order,
+ :categories_mode,
+ :categories_link_target,
+ :categories_custom_url,
+ :categories_status,
+ :categories_visibility_nav,
+ :categories_visibility_box,
+ :date_added,
+ :last_modified)');
+
+ $tQry->bindTable(':table_categories', TABLE_CATEGORIES);
+ $tQry->bindValue(':categories_image' , $page['categories_image']);
+ $tQry->bindInt (':parent_id' , $page['parent_id']);
+ $tQry->bindInt (':sort_order' , $page['sort_order']);
+ $tQry->bindValue(':categories_mode' , $page['categories_mode']);
+ $tQry->bindInt (':categories_link_target' , $page['categories_link_target']);
+ $tQry->bindValue(':categories_custom_url' , $page['categories_custom_url']);
+ $tQry->bindInt (':categories_status' , $page['categories_status']);
+ $tQry->bindInt (':categories_visibility_nav', $page['categories_visibility_nav']);
+ $tQry->bindInt (':categories_visibility_box', $page['categories_visibility_box']);
+ $tQry->bindDate (':date_added' , $page['date_added']);
+ $tQry->bindDate (':last_modified' , $page['last_modified']);
+ $tQry->execute();
+
+ $insert_id = $target_db->nextID();
+ $page_pages[$pID] = $insert_id;
+ }
+
+ $sQry->freeResult();
+ }
- require_once('../includes/database_tables.php');
+ // END LOAD PAGE PAGES FROM SOURCE DB
- require_once('../includes/classes/database/mysqli.php');
- $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
- $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+ // LOAD PAGE PAGES DESCRIPTION TO TARGET DB
- if ($source_db->isError() === false) {
- $source_db->selectDatabase($s_db['DB_DATABASE']);
- }
+ foreach ($page_pages as $pID => $insert_id) {
+
+ $sQry = $source_db->query('SELECT * FROM pages_description WHERE pages_id = ' . $pID);
+ $sQry->execute();
- if ($source_db->isError()) {
- $this->_msg = $source_db->getError();
- return false;
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ while ($sQry->next()) {
+
+ $c_keyword = self::generateCleanPermalink($sQry->value('pages_title'));
+
+ if (preg_match('/category$/i', $c_keyword)) {
+ $c_keyword .= '-link';
+ }
+
+ $tQry = $target_db->query('INSERT INTO :table_categories_desc (categories_id,
+ language_id,
+ categories_name,
+ categories_menu_name,
+ categories_blurb,
+ categories_description,
+ categories_keyword,
+ categories_tags)
+ VALUES (:categories_id,
+ :language_id,
+ :categories_name,
+ :categories_menu_name,
+ :categories_blurb,
+ :categories_description,
+ :categories_keyword,
+ :categories_tags)');
+
+ $tQry->bindTable(':table_categories_desc', TABLE_CATEGORIES_DESCRIPTION);
+ $tQry->bindInt (':categories_id' , $insert_id);
+ $tQry->bindInt (':language_id' , $sQry->value('language_id') );
+ $tQry->bindValue(':categories_name' , $sQry->value('pages_title') );
+ $tQry->bindValue(':categories_menu_name' , $sQry->value('pages_menu_name') );
+ $tQry->bindValue(':categories_blurb' , $sQry->value('pages_blurb') );
+ $tQry->bindValue(':categories_description', $sQry->value('pages_body') );
+ $tQry->bindValue(':categories_keyword' , $c_keyword);
+ $tQry->bindValue(':categories_tags' , $sQry->value('pages_meta_keywords') );
+ $tQry->execute();
+ }
+ }
}
- // END CONNNECT TO SOURCE DB
- // CONNNECT TO TARGET DB
-
- $class = 'lC_Database_' . $t_db['DB_CLASS'];
- $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+ // END LOAD PAGE PAGES DESCRIPTION TO TARGET DB
- if ($target_db->isError() === false) {
- $target_db->selectDatabase($t_db['DB_DATABASE']);
- }
+ // LOAD CATEGORY PAGES PERMALINK FROM TARGET DB
+
+ $permalink_array = array();
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
+ foreach ($page_categories as $cID => $insert_id) {
+ $tQry = $target_db->query("SELECT c.categories_id, cd.language_id, cd.categories_keyword FROM " . $t_db['DB_PREFIX'] . "categories AS c, " . $t_db['DB_PREFIX'] . "categories_description AS cd WHERE c.categories_id = " . $insert_id . " AND c.categories_id = cd.categories_id");
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ if ($tQry->numberOfRows() > 0) {
+ while ($tQry->next()) {
+ $permalink = array(
+ 'item_id' => $tQry->value('categories_id')
+ , 'language_id' => $tQry->value('language_id')
+ , 'type' => 1
+ , 'query' => ''
+ , 'permalink' => $tQry->value('categories_keyword')
+ );
+
+ $permalink_array[] = $permalink;
+ }
+ }
}
-
- // TRUNCATE PRODUCTS IMAGES TABLES IN TARGET DB
- $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_IMAGES);
- $tQry->execute();
-
- // END TRUNCATE PRODUCTS IMAGES TABLES IN TARGET DB
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
- $tQry->execute();
+ // END LOAD CATEGORY PAGES PERMALINK FROM SOURCE DB
- // LOAD products_images_groups FROM TARGET DB
- $map = $this->_data_mapping['images_groups'];
+ // LOAD PAGES PAGES PERMALINK FROM TARGET DB
- $products_images_groups = array();
- $tQry = $target_db->query('SELECT * FROM ' . TABLE_PRODUCTS_IMAGES_GROUPS);
- $tQry->execute();
+ foreach ($page_pages as $cID => $insert_id) {
+ $tQry = $target_db->query("SELECT c.categories_id, cd.language_id, cd.categories_keyword FROM " . $t_db['DB_PREFIX'] . "categories AS c, " . $t_db['DB_PREFIX'] . "categories_description AS cd WHERE c.categories_id = " . $insert_id . " AND c.categories_id = cd.categories_id");
+ $tQry->execute();
- if ($tQry->numberOfRows() > 0) {
- $cnt = 0;
- while ( $tQry->next() ) {
- $images_group = array(
- 'id' => $tQry->value($map['id'])
- , 'language_id' => $tQry->value($map['language_id'])
- , 'title' => $tQry->value($map['title'])
- , 'code' => $tQry->value($map['code'])
- , 'size_width' => $tQry->value($map['size_width'])
- , 'size_height' => $tQry->value($map['size_height'])
- , 'force_size' => $tQry->value($map['force_size'])
- );
-
- $products_images_groups[] = $images_group;
-
- $cnt++;
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
+ if ($tQry->numberOfRows() > 0) {
+ while ($tQry->next()) {
+ $permalink = array(
+ 'item_id' => $tQry->value('categories_id')
+ , 'language_id' => $tQry->value('language_id')
+ , 'type' => 1
+ , 'query' => ''
+ , 'permalink' => $tQry->value('categories_keyword')
+ );
+ $permalink_array[] = $permalink;
+ }
+ }
$tQry->freeResult();
}
+
+ // END LOAD PAGES PAGES PERMALINK FROM SOURCE DB
- // END LOAD products_images_groups FROM TARGET DB
+ // SAVE CATEGORY PAGES AND PAGE PAGES PERMALINKS TO TARGET DB
- // LOAD products images info FROM SOURCE DB
- $map = $this->_data_mapping['images'];
+ $iCnt = 0;
+
+ foreach ($permalink_array as $permalink) {
- $source_images = array();
- $sQry = $source_db->query('SELECT * FROM products ORDER BY products_id');
- $sQry->execute();
-
- if ($sQry->numberOfRows() > 0) {
- $cnt = 0;
- while ($sQry->next()) {
-
- $product_main_image = '';
- if (strlen($sQry->value($map['products_image_lrg'])) > 0) $product_main_image = $sQry->value($map['products_image_lrg']);
- else if (strlen($sQry->value($map['products_image_med'])) > 0) $product_main_image = $sQry->value($map['products_image_med']);
- else $product_main_image = $sQry->value($map['products_image']);
-
- $images = array(
- 'products_image' => $product_main_image
- , 'products_image_xl_1' => $sQry->value($map['products_image_xl_1'])
- , 'products_image_xl_2' => $sQry->value($map['products_image_xl_2'])
- , 'products_image_xl_3' => $sQry->value($map['products_image_xl_3'])
- , 'products_image_xl_4' => $sQry->value($map['products_image_xl_4'])
- , 'products_image_xl_5' => $sQry->value($map['products_image_xl_5'])
- , 'products_image_xl_6' => $sQry->value($map['products_image_xl_6'])
- );
-
- $images_info = array(
- 'products_id' => $sQry->value($map['products_id'])
- , 'images' => serialize($images)
- , 'status' => NULL
- );
-
- $source_images[] = $images_info;
- $cnt++;
- }
+ // #### getCPATH CODE
+
+ $cat_list = "cPath=" . lC_LocalUpgrader::getcdsPath($permalink['item_id'], null);
- $sQry->freeResult();
- }
-
- // END LOAD products images info FROM SOURCE DB
-
- // PROCESS tmp_image_import DATA
- $to_zip = array();
-
- foreach ($source_images as $k => $images_info) {
+ // #### END getCPATH CODE
- $products_id = $images_info['products_id'];
- $image_array = unserialize($images_info['images']);
+ $tQry = $target_db->query('INSERT INTO :table_permalink (item_id,
+ language_id,
+ `type`,
+ query,
+ permalink)
+ VALUES (:item_id,
+ :language_id,
+ :type,
+ :query,
+ :permalink)');
- $sorder = 0;
- foreach ($image_array as $k => $img_info) {
-
- if (empty($img_info)) continue;
+ $tQry->bindTable(':table_permalink', TABLE_PERMALINKS);
+ $tQry->bindInt (':item_id' , $permalink['item_id']);
+ $tQry->bindInt (':language_id', $permalink['language_id']);
+ $tQry->bindInt (':type' , $permalink['type']);
+ $tQry->bindValue(':query' , $cat_list);
+ $tQry->bindValue(':permalink' , self::generateCleanPermalink($permalink['permalink']));
+ $tQry->execute();
- $r = $this->saveToProductsImages($target_db, $products_id, $img_info, $sorder, ($k == 'products_image' ? 1 : 0 ));
-
- if ($r == false) {
- $this->_msg = $target_db->getError();
- return false;
- }
- // if not exist, loop to next;
- if (!file_exists($source_img_dir . $img_info) || !is_readable($source_img_dir . $img_info)) {
- continue;
- }
- $files_to_zip[] = $source_img_dir.$img_info;
- $to_zip[] = $img_info;
-
- $sorder++;
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
-
- $source_images[$k]['status'] = 1;
- }
-
- $o_dir = getcwd();
- chdir($source_img_dir);
- $target_zip = 'my-product-images-' . time() . '.zip';
-
- $result = $this->create_zip($to_zip, $target_img_dir . $target_zip);
- if ($result == false) {
- $this->_msg = $lC_Language->get('upgrade_step4_import_product_images_zipcreateerror');
- return false;
- }
- $result = $this->extract_zip($target_img_dir . $target_zip, $target_img_dir);
- if ($result == false) {
- $this->_msg = $lC_Language->get('upgrade_step4_import_product_images_zipextracteerror');
- return false;
}
-
- unlink($target_img_dir . $target_zip);
- $this->chmod_r($target_img_dir);
- chdir($o_dir);
+
+ $tQry->freeResult();
- // PROCESS tmp_image_import DATA
+ // END LOAD PERMALINK TO TARGET DB
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = ""');
$tQry->execute();
- //SET THE RESIZE IMAGES FLAG
- if (!file_exists('../includes/work/resize.tmp')) {
- file_put_contents('../includes/work/resize.tmp', '1');
- }
-
$source_db->disconnect();
- $target_db->disconnect();
+ $target_db->disconnect();
return true;
- } // end importImages
-
+ } // end importPages
+
/*
- * function name : importCategoryImages()
+ * function name : importCustomers()
*
- * description : load category images from the source server to the new loaded7 server
+ * description : load customers data from the source database to loaded7
*
* returns : true or false
*
*/
- public function importCategoryImages() {
- global $lC_Language;
-
- $source_img_dir = $this->_sDB['INSTALL_PATH'].$this->_sDB['IMAGE_PATH'];
- $target_img_dir = getcwd() . '/../images/categories/';
-
+ public function importCustomers($switch = null) {
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
+ $map = $this->_data_mapping['customers'];
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
require_once('../includes/database_tables.php');
-
+
require_once('../includes/classes/database/mysqli.php');
$class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
@@ -3167,264 +3244,299 @@ public function importCategoryImages() {
// END CONNNECT TO TARGET DB
+ // TRUNCATE CUSTOMERS TABLES IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_CUSTOMERS);
+ $tQry->execute();
+
+ // END TRUNCATE CUSTOMERS TABLES IN TARGET DB
+
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
- // LOAD category images FROM SOURCE DB
-
- $map = $this->_data_mapping['categories'];
+ // LOAD CUSTOMERS FROM SOURCE DB
- $source_categ_images = array();
- $sQry = $source_db->query('SELECT * FROM categories ORDER BY categories_id');
+ $sQry = $source_db->query('SELECT * FROM customers c LEFT JOIN customers_info ci ON c.customers_id = ci.customers_info_id');
$sQry->execute();
-
+
+ $customers = array();
if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
+ $customer = array(
+ 'customers_id' => $sQry->value($map['customers_id'])
+ , 'customers_group_id' => ($sQry->value($map['customers_group_id']) != null) ? $sQry->value($map['customers_group_id']) : 1
+ , 'customers_gender' => $sQry->value($map['customers_gender'])
+ , 'customers_firstname' => $sQry->value($map['customers_firstname'])
+ , 'customers_lastname' => $sQry->value($map['customers_lastname'])
+ , 'customers_dob' => $sQry->value($map['customers_dob'])
+ , 'customers_email_address' => $sQry->value($map['customers_email_address'])
+ , 'customers_default_address_id' => $sQry->value($map['customers_default_address_id'])
+ , 'customers_telephone' => ($sQry->value($map['customers_telephone']) != '' || $sQry->value($map['customers_telephone']) != NULL) ? $sQry->value($map['customers_telephone']) : ""
+ , 'customers_fax' => ($sQry->value($map['customers_fax']) != '' || $sQry->value($map['customers_fax']) != NULL) ? $sQry->value($map['customers_fax']) : ""
+ , 'customers_password' => $sQry->value($map['customers_password'])
+ , 'customers_newsletter' => $sQry->value($map['customers_newsletter'])
+ , 'customers_status' => 1
+ , 'customers_ip_address' => ($sQry->value($map['customers_ip_address']) != '' || $sQry->value($map['customers_ip_address']) != NULL) ? $sQry->value($map['customers_ip_address']) : ""
+ , 'date_last_logon' => ($sQry->value($map['date_last_logon']) != '' || $sQry->value($map['date_last_logon']) != NULL) ? $sQry->value($map['date_last_logon']) : ""
+ , 'number_of_logons' => ($sQry->value($map['number_of_logons']) != '' || $sQry->value($map['number_of_logons']) != NULL) ? $sQry->value($map['number_of_logons']) : ""
+ , 'date_account_created' => ($sQry->value($map['date_account_created']) != '' || $sQry->value($map['date_account_created']) != NULL) ? $sQry->value($map['date_account_created']) : ""
+ , 'date_account_last_modified' => ($sQry->value($map['date_account_last_modified']) != '' || $sQry->value($map['date_account_last_modified']) != NULL) ? $sQry->value($map['date_account_last_modified']) : ""
+ , 'global_product_notifications' => ($sQry->value($map['global_product_notifications']) != '' || $sQry->value($map['global_product_notifications']) != NULL) ? $sQry->value($map['global_product_notifications']) : 1
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_customers (customers_id,
+ customers_group_id,
+ customers_gender,
+ customers_firstname,
+ customers_lastname,
+ customers_dob,
+ customers_email_address,
+ customers_default_address_id,
+ customers_telephone,
+ customers_fax,
+ customers_password,
+ customers_newsletter,
+ customers_status,
+ customers_ip_address,
+ date_last_logon,
+ number_of_logons,
+ date_account_created,
+ date_account_last_modified,
+ global_product_notifications)
+ VALUES (:customers_id,
+ :customers_group_id,
+ :customers_gender,
+ :customers_firstname,
+ :customers_lastname,
+ :customers_dob,
+ :customers_email_address,
+ :customers_default_address_id,
+ :customers_telephone,
+ :customers_fax,
+ :customers_password,
+ :customers_newsletter,
+ :customers_status,
+ :customers_ip_address,
+ :date_last_logon,
+ :number_of_logons,
+ :date_account_created,
+ :date_account_last_modified,
+ :global_product_notifications)');
+
+ $tQry->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $tQry->bindInt (':customers_id' , $customer['customers_id']);
+ $tQry->bindInt (':customers_group_id' , $customer['customers_group_id']);
+ $tQry->bindValue(':customers_gender' , $customer['customers_gender']);
+ $tQry->bindValue(':customers_firstname' , $customer['customers_firstname']);
+ $tQry->bindValue(':customers_lastname' , $customer['customers_lastname']);
+ $tQry->bindDate (':customers_dob' , $customer['customers_dob']);
+ $tQry->bindValue(':customers_email_address' , $customer['customers_email_address']);
+ $tQry->bindInt (':customers_default_address_id', $customer['customers_default_address_id']);
+ $tQry->bindValue(':customers_telephone' , $customer['customers_telephone']);
+ $tQry->bindValue(':customers_fax' , $customer['customers_fax']);
+ $tQry->bindValue(':customers_password' , $customer['customers_password']);
+ $tQry->bindValue(':customers_newsletter' , $customer['customers_newsletter']);
+ $tQry->bindInt (':customers_status' , $customer['customers_status']);
+ $tQry->bindValue(':customers_ip_address' , $customer['customers_ip_address']);
+ $tQry->bindDate (':date_last_logon' , $customer['date_last_logon']);
+ $tQry->bindInt (':number_of_logons' , $customer['number_of_logons']);
+ $tQry->bindDate (':date_account_created' , $customer['date_account_created']);
+ $tQry->bindDate (':date_account_last_modified' , $customer['date_account_last_modified']);
+ $tQry->bindInt (':global_product_notifications', $customer['global_product_notifications']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
- if (!file_exists($source_img_dir . $sQry->value($map['categories_image'])) ||
- !is_readable($source_img_dir . $sQry->value($map['categories_image']))
- ) {
- continue;
- }
-
- $images_info = array(
- 'categories_id' => $sQry->value($map['categories_id'])
- , 'categories_image' => $sQry->value($map['categories_image'])
- );
-
- $source_categ_images[] = $images_info;
$cnt++;
}
$sQry->freeResult();
}
- // END LOAD category images FROM SOURCE DB
+ // END LOAD CUSTOMERS FROM SOURCE DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
- // COPY category images TO TARGET SERVER
-
- foreach ($source_categ_images as $image) {
-
- $img_info = $image['categories_image'];
-
- if (empty($img_info)) continue;
-
- // if not exist, loop to next ;
- if (!file_exists($source_img_dir.$img_info) ||
- !is_readable($source_img_dir.$img_info)
- ) {
- continue;
- }
- $to_zip[] = $img_info;
-
- }
-
- $o_dir = getcwd();
- chdir($source_img_dir);
- $target_zip = 'my-category-images-' . time() . '.zip';
-
- $result = $this->create_zip($to_zip, $target_img_dir . $target_zip);
- if ($result == false) {
- $this->_msg = $lC_Language->get('upgrade_step4_import_category_images_zipcreateerror');
- return false;
- }
-
- $result = $this->extract_zip($target_img_dir . $target_zip, $target_img_dir);
- if ($result == false) {
- $this->_msg = $lC_Language->get('upgrade_step4_import_category_images_zipextracterror');
- return false;
- }
-
- unlink($target_img_dir . $target_zip);
- $this->chmod_r($target_img_dir);
- chdir($o_dir);
-
- // END COPY category images TO TARGET SERVER
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
- $tQry->execute();
-
- $source_db->disconnect();
- $target_db->disconnect();
-
- return true;
-
- } // end importCategoryImages
-
- public function saveToProductsImages($target_db, $pid, $image, $sort, $default_flag = 1) {
-
- $image = end(explode('/', $image));
-
- $tQry = $target_db->query('INSERT INTO :table_products_images (products_id,
- image,
- default_flag,
- sort_order)
- VALUES (:products_id,
- :image,
- :default_flag,
- :sort_order)');
-
- $tQry->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
- $tQry->bindInt (':products_id' , $pid);
- $tQry->bindValue(':image' , $image);
- $tQry->bindInt (':default_flag', $default_flag);
- $tQry->bindInt (':sort_order' , $sort);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
+ $source_db->disconnect();
+ $target_db->disconnect();
return true;
- } // end saveToProductsImages
+ } // end importCustomers
/*
- * function name : importCustomerGroups()
+ * function name : importAddressBook()
*
- * description : load customer group data from source to loaded7
+ * description : load address book data from the source database to loaded7
*
* returns : true or false
*
*/
- public function importCustomerGroups($switch = null) {
- global $lC_Language;
-
+ public function importAddressBook($switch = null) {
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
- $map = $this->_data_mapping['customers_groups'];
-
+
if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
// CONNNECT TO SOURCE DB
-
+
require_once('../includes/database_tables.php');
-
+
require_once('../includes/classes/database/mysqli.php');
$class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
-
+
if ($source_db->isError() === false) {
$source_db->selectDatabase($s_db['DB_DATABASE']);
}
-
+
if ($source_db->isError()) {
$this->_msg = $source_db->getError();
return false;
}
// END CONNNECT TO SOURCE DB
-
+
// CONNNECT TO TARGET DB
$class = 'lC_Database_' . $t_db['DB_CLASS'];
$target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
-
+
if ($target_db->isError() === false) {
$target_db->selectDatabase($t_db['DB_DATABASE']);
}
-
+
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
// END CONNNECT TO TARGET DB
+
+ // TRUNCATE ADDRESS BOOK TABLES IN TARGET DB
- // LOAD CUSTOMERS GROUPS FROM SOURCE DB
+ $tQry = $target_db->query('truncate table ' . TABLE_ADDRESS_BOOK);
+ $tQry->execute();
- //$tQry = $target_db->query('SELECT COUNT(*) AS exist
- // FROM information_schema.tables
- // WHERE table_schema = "' . $t_db['DB_DATABASE'] . '"
- // AND table_name = "' . TABLE_CUSTOMERS_GROUPS . '"');
- //$tQry->execute();
- //$tQry->next();
- //if ($tQry->value('exist') != '1') return true;
- //$tQry->freeResult();
+ // END TRUNCATE ADDRESS BOOK TABLES IN TARGET DB
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
- $tQry->execute();
-
- $customers_groups = array();
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD ADDRESS BOOK FROM SOURCE DB
- $sQry = $source_db->query('SELECT * FROM customers_groups');
+ $map = $this->_data_mapping['address_book'];
+
+ $sQry = $source_db->query('SELECT * FROM address_book');
$sQry->execute();
-
- if ($sQry->numberOfRows() > 0) {
- // TRUNCATE CUSTOMERS GROUPS TABLES IN TARGET DB
- $tQry = $target_db->query('truncate table ' . TABLE_CUSTOMERS_GROUPS);
- $tQry->execute();
-
+
+ $customers = array();
+ if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
- $customers_group = array(
- 'customers_group_id' => $sQry->value('customers_group_id')
- , 'language_id' => 1
- , 'customers_group_name' => $sQry->value('customers_group_name')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_customers_groups (customers_group_id,
- language_id,
- customers_group_name)
- VALUES (:customers_group_id,
- :language_id,
- :customers_group_name)');
-
- $tQry->bindTable(':table_customers_groups', TABLE_CUSTOMERS_GROUPS);
- $tQry->bindInt (':customers_group_id' , $customers_group['customers_group_id']);
- $tQry->bindInt (':language_id' , $customers_group['language_id']);
- $tQry->bindValue(':customers_group_name', $customers_group['customers_group_name']);
- $tQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
+ $address = array(
+ 'address_book_id' => $sQry->value($map['address_book_id'])
+ , 'customers_id' => $sQry->value($map['customers_id'])
+ , 'entry_gender' => $sQry->value($map['entry_gender'])
+ , 'entry_company' => $sQry->value($map['entry_company'])
+ , 'entry_firstname' => $sQry->value($map['entry_firstname'])
+ , 'entry_lastname' => $sQry->value($map['entry_lastname'])
+ , 'entry_street_address' => $sQry->value($map['entry_street_address'])
+ , 'entry_suburb' => $sQry->value($map['entry_suburb'])
+ , 'entry_postcode' => $sQry->value($map['entry_postcode'])
+ , 'entry_city' => $sQry->value($map['entry_city'])
+ , 'entry_state' => $sQry->value($map['entry_state'])
+ , 'entry_country_id' => $sQry->value($map['entry_country_id'])
+ , 'entry_zone_id' => $sQry->value($map['entry_zone_id'])
+ , 'entry_telephone' => $sQry->value($map['entry_telephone'])
+ , 'entry_fax' => $sQry->value($map['entry_fax'])
+ );
+
+ // get zone_name from source db
+ if ($sQry->value($map['entry_zone_id']) != 0) {
+ $znQry = $source_db->query("SELECT zone_name FROM zones WHERE zone_id = " . $sQry->value($map['entry_zone_id']));
+ $znQry->execute();
+ $zone_name = $znQry->value('zone_name');
+ } else {
+ $zone_name = $sQry->value($map['entry_state']);
}
- $customers_group_data = array(
- 'customers_group_id' => $sQry->value('customers_group_id')
- , 'baseline_discount' => $sQry->value('group_discount')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_customers_groups_data (customers_group_id,
- baseline_discount)
- VALUES (:customers_group_id,
- :baseline_discount)');
+ // get zone_code from new db
+ $nzQry = $target_db->query("SELECT zone_id FROM " . $t_db['DB_PREFIX'] . "zones WHERE zone_country_id = " . $sQry->value($map['entry_country_id']) . " AND zone_name = '" . $zone_name . "'");
+ $nzQry->execute();
- $tQry->bindTable(':table_customers_groups_data', TABLE_CUSTOMERS_GROUPS_DATA);
- $tQry->bindInt (':customers_group_id', $customers_group_data['customers_group_id']);
- $tQry->bindValue(':baseline_discount' , $customers_group_data['baseline_discount']);
+ $tQry = $target_db->query('INSERT INTO :table_address_book (address_book_id,
+ customers_id,
+ entry_gender,
+ entry_company,
+ entry_firstname,
+ entry_lastname,
+ entry_street_address,
+ entry_suburb,
+ entry_postcode,
+ entry_city,
+ entry_state,
+ entry_country_id,
+ entry_zone_id,
+ entry_telephone,
+ entry_fax)
+ VALUES (:address_book_id,
+ :customers_id,
+ :entry_gender,
+ :entry_company,
+ :entry_firstname,
+ :entry_lastname,
+ :entry_street_address,
+ :entry_suburb,
+ :entry_postcode,
+ :entry_city,
+ :entry_state,
+ :entry_country_id,
+ :entry_zone_id,
+ :entry_telephone,
+ :entry_fax)');
+
+ $tQry->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+ $tQry->bindInt (':address_book_id' , $address['address_book_id']);
+ $tQry->bindInt (':customers_id' , $address['customers_id']);
+ $tQry->bindValue(':entry_gender' , $address['entry_gender']);
+ $tQry->bindValue(':entry_company' , $address['entry_company']);
+ $tQry->bindValue(':entry_firstname' , $address['entry_firstname']);
+ $tQry->bindValue(':entry_lastname' , $address['entry_lastname']);
+ $tQry->bindValue(':entry_street_address', $address['entry_street_address']);
+ $tQry->bindValue(':entry_suburb' , $address['entry_suburb']);
+ $tQry->bindValue(':entry_postcode' , $address['entry_postcode']);
+ $tQry->bindValue(':entry_city' , $address['entry_city']);
+ $tQry->bindValue(':entry_state' , $zone_name);
+ $tQry->bindInt (':entry_country_id' , $address['entry_country_id']);
+ $tQry->bindInt (':entry_zone_id' , $nzQry->value('zone_id'));
+ $tQry->bindValue(':entry_telephone' , $address['entry_telephone']);
+ $tQry->bindValue(':entry_fax' , $address['entry_fax']);
$tQry->execute();
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
-
+
$cnt++;
}
- $sQry->freeResult();
-
- // get the lowest customers group id
- $lidQry = $source_db->query("SELECT MIN(customers_group_id) AS customers_group_id FROM customers_groups");
- $lidQry->execute();
-
- // set default customers group to lowest resulting id in above query
- $tQry = $target_db->query("UPDATE :table_configuration SET configuration_value = :configuration_value WHERE configuration_key = 'DEFAULT_CUSTOMERS_GROUP_ID'");
- $tQry->bindTable(':table_configuration', TABLE_CONFIGURATION);
- $tQry->bindInt(':configuration_value', $lidQry->value('customers_group_id'));
- $tQry->execute();
+ $sQry->freeResult();
}
- // END LOAD CUSTOMERS GROUPS FROM SOURCE DB
-
+ // END LOAD ADDRESS BOOK FROM SOURCE DB
+
// DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
$tQry->execute();
$source_db->disconnect();
@@ -3432,19 +3544,22 @@ public function importCustomerGroups($switch = null) {
return true;
- } // end importCustomerGroups
+ } // end importAddressBook
/*
- * function name : importOrders()
+ * function name : importImages()
*
- * description : load orders, orders_products, orders_status, orders_status_history, orders_total and orders_products_download
- * from the source database to the new loaded7 database
+ * description : load product images to loaded7
*
* returns : true or false
*
*/
- public function importOrders($switch = null) {
-
+ public function importImages() {
+ global $lC_Language;
+
+ $source_img_dir = $this->_sDB['INSTALL_PATH'].$this->_sDB['IMAGE_PATH'];
+ $target_img_dir = getcwd() . '/../images/products/originals/';
+
$s_db = $this->_sDB;
$t_db = $this->_tDB;
@@ -3452,385 +3567,642 @@ public function importOrders($switch = null) {
// CONNNECT TO SOURCE DB
- require_once('../includes/database_tables.php');
-
+ require_once('../includes/database_tables.php');
+
require_once('../includes/classes/database/mysqli.php');
$class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
$source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
-
+
if ($source_db->isError() === false) {
$source_db->selectDatabase($s_db['DB_DATABASE']);
}
-
+
if ($source_db->isError()) {
$this->_msg = $source_db->getError();
return false;
}
-
// END CONNNECT TO SOURCE DB
// CONNNECT TO TARGET DB
$class = 'lC_Database_' . $t_db['DB_CLASS'];
$target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
-
+
if ($target_db->isError() === false) {
$target_db->selectDatabase($t_db['DB_DATABASE']);
}
-
+
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
- // END CONNNECT TO TARGET DB
-
- // ##########
-
- // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
- $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
- $tQry->execute();
-
- // ##########
-
- // TRUNCATE ORDERS TABLE IN TARGET DB
+ // TRUNCATE PRODUCTS IMAGES TABLES IN TARGET DB
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS);
- $tQry->execute();
-
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_PRODUCTS);
+ $tQry = $target_db->query('truncate table ' . TABLE_PRODUCTS_IMAGES);
$tQry->execute();
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_STATUS);
- $tQry->execute();
+ // END TRUNCATE PRODUCTS IMAGES TABLES IN TARGET DB
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_STATUS_HISTORY);
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
$tQry->execute();
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_TOTAL);
+ // LOAD products_images_groups FROM TARGET DB
+ $map = $this->_data_mapping['images_groups'];
+
+ $products_images_groups = array();
+ $tQry = $target_db->query('SELECT * FROM ' . TABLE_PRODUCTS_IMAGES_GROUPS);
$tQry->execute();
+
+ if ($tQry->numberOfRows() > 0) {
+ $cnt = 0;
+ while ( $tQry->next() ) {
+ $images_group = array(
+ 'id' => $tQry->value($map['id'])
+ , 'language_id' => $tQry->value($map['language_id'])
+ , 'title' => $tQry->value($map['title'])
+ , 'code' => $tQry->value($map['code'])
+ , 'size_width' => $tQry->value($map['size_width'])
+ , 'size_height' => $tQry->value($map['size_height'])
+ , 'force_size' => $tQry->value($map['force_size'])
+ );
+
+ $products_images_groups[] = $images_group;
- $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD);
- $tQry->execute();
-
- // END TRUNCATE ORDERS TABLE IN TARGET DB
+ $cnt++;
+ }
+
+ $tQry->freeResult();
+ }
- // ##########
+ // END LOAD products_images_groups FROM TARGET DB
- // LOAD ORDERS STATUS FROM SOURCE DB
-
- $map = $this->_data_mapping['orders_status'];
- $orders_status = array();
+ // LOAD products images info FROM SOURCE DB
+ $map = $this->_data_mapping['images'];
- $sQry = $source_db->query('SELECT * FROM orders_status');
+ $source_images = array();
+ $sQry = $source_db->query('SELECT * FROM products ORDER BY products_id');
$sQry->execute();
-
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
+
+ if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
- if ($sQry->value($map['language_id']) == $this->_languages_id_default && $sQry->value($map['orders_status_name']) == 'Pending') {
- $pending_id = $sQry->value($map['orders_status_id']);
- }
- $orders_stat = array(
- 'orders_status_id' => $sQry->value($map['orders_status_id'])
- , 'language_id' => $sQry->value($map['language_id'])
- , 'orders_status_name' => $sQry->value($map['orders_status_name'])
- );
-
- $tQry = $target_db->query('INSERT INTO :table_orders_status (orders_status_id,
- language_id,
- orders_status_name)
- VALUES (:orders_status_id,
- :language_id,
- :orders_status_name)');
+
+ $product_main_image = '';
+ if (strlen($sQry->value($map['products_image_lrg'])) > 0) $product_main_image = $sQry->value($map['products_image_lrg']);
+ else if (strlen($sQry->value($map['products_image_med'])) > 0) $product_main_image = $sQry->value($map['products_image_med']);
+ else $product_main_image = $sQry->value($map['products_image']);
- $tQry->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
- $tQry->bindInt (':orders_status_id' , $orders_stat['orders_status_id']);
- $tQry->bindInt (':language_id' , $orders_stat['language_id']);
- $tQry->bindValue(':orders_status_name', $orders_stat['orders_status_name']);
- $tQry->execute();
+ $images = array(
+ 'products_image' => $product_main_image
+ , 'products_image_xl_1' => $sQry->value($map['products_image_xl_1'])
+ , 'products_image_xl_2' => $sQry->value($map['products_image_xl_2'])
+ , 'products_image_xl_3' => $sQry->value($map['products_image_xl_3'])
+ , 'products_image_xl_4' => $sQry->value($map['products_image_xl_4'])
+ , 'products_image_xl_5' => $sQry->value($map['products_image_xl_5'])
+ , 'products_image_xl_6' => $sQry->value($map['products_image_xl_6'])
+ );
+
+ $images_info = array(
+ 'products_id' => $sQry->value($map['products_id'])
+ , 'images' => serialize($images)
+ , 'status' => NULL
+ );
+
+ $source_images[] = $images_info;
$cnt++;
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
}
$sQry->freeResult();
}
- // END LOAD ORDERS STATUS FROM SOURCE DB
-
- $orders_stat = null;
-
- // ##########
-
- // LOAD ORDERS STATUS HISTORY FROM SOURCE DB
+ // END LOAD products images info FROM SOURCE DB
- $map = $this->_data_mapping['orders_status_history'];
- $orders_status_histories = array();
-
- $sQry = $source_db->query('SELECT * FROM orders_status_history');
- $sQry->execute();
+ // PROCESS tmp_image_import DATA
+ $to_zip = array();
- $numrows = $sQry->numberOfRows();
- if ($numrows > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $orders_status_history = array(
- 'orders_status_history_id' => $sQry->value($map['orders_status_history_id'])
- , 'orders_id' => $sQry->value($map['orders_id'])
- , 'orders_status_id' => $sQry->value($map['orders_status_id'])
- , 'date_added' => $sQry->value($map['date_added'])
- , 'customer_notified' => $sQry->value($map['customer_notified'])
- , 'comments' => $sQry->value($map['comments'])
- );
-
- $tQry = $target_db->query('INSERT INTO :table_orders_status_history (orders_status_history_id,
- orders_id,
- orders_status_id,
- date_added,
- customer_notified,
- comments)
- VALUES (:orders_status_history_id,
- :orders_id,
- :orders_status_id,
- :date_added,
- :customer_notified,
- :comments)');
+ foreach ($source_images as $k => $images_info) {
+
+ $products_id = $images_info['products_id'];
+ $image_array = unserialize($images_info['images']);
+
+ $sorder = 0;
+ foreach ($image_array as $k => $img_info) {
- $tQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
- $tQry->bindInt (':orders_status_history_id', $orders_status_history['orders_status_history_id']);
- $tQry->bindInt (':orders_id' , $orders_status_history['orders_id']);
- $tQry->bindInt (':orders_status_id' , $orders_status_history['orders_status_id']);
- $tQry->bindValue(':date_added' , $orders_status_history['date_added']);
- $tQry->bindInt (':customer_notified' , $orders_status_history['customer_notified']);
- $tQry->bindValue(':comments' , $orders_status_history['comments']);
- $tQry->execute();
-
- $cnt++;
+ if (empty($img_info)) continue;
+
+ $r = $this->saveToProductsImages($target_db, $products_id, $img_info, $sorder, ($k == 'products_image' ? 1 : 0 ));
- if ($target_db->isError()) {
+ if ($r == false) {
$this->_msg = $target_db->getError();
return false;
}
+ // if not exist, loop to next;
+ if (!file_exists($source_img_dir . $img_info) || !is_readable($source_img_dir . $img_info)) {
+ continue;
+ }
+ $files_to_zip[] = $source_img_dir.$img_info;
+ $to_zip[] = $img_info;
+
+ $sorder++;
}
-
- $sQry->freeResult();
+
+ $source_images[$k]['status'] = 1;
}
- // END LOAD ORDERS STATUS HISTORY FROM SOURCE DB
+ $o_dir = getcwd();
+ chdir($source_img_dir);
+ $target_zip = 'my-product-images-' . time() . '.zip';
- $orders_status_history = null;
-
- // ##########
+ $result = $this->create_zip($to_zip, $target_img_dir . $target_zip);
+ if ($result == false) {
+ $this->_msg = $lC_Language->get('upgrade_step4_import_product_images_zipcreateerror');
+ return false;
+ }
- // LOAD ORDERS TOTAL FROM SOURCE DB
-
- $map = $this->_data_mapping['orders_total'];
- $orders_total = array();
+ $result = $this->extract_zip($target_img_dir . $target_zip, $target_img_dir);
+ if ($result == false) {
+ $this->_msg = $lC_Language->get('upgrade_step4_import_product_images_zipextracteerror');
+ return false;
+ }
+
+ unlink($target_img_dir . $target_zip);
+ $this->chmod_r($target_img_dir);
+ chdir($o_dir);
- $sQry = $source_db->query('SELECT * FROM orders_total');
- $sQry->execute();
+ // PROCESS tmp_image_import DATA
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ //SET THE RESIZE IMAGES FLAG
+ if (!file_exists('../includes/work/resize.tmp')) {
+ file_put_contents('../includes/work/resize.tmp', '1');
+ }
- $orders_total_map = array(
- 'ot_coupon' => 'coupon'
- , 'ot_shipping' => 'shipping'
- , 'ot_tax' => 'tax'
- , 'ot_subtotal' => 'subtotal'
- , 'ot_total' => 'total'
- , 'xxxxxxxx' => 'low_order_fee'
- );
+ $source_db->disconnect();
+ $target_db->disconnect();
- $numrows= $sQry->numberOfRows();
- if ($numrows > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $order_total = array(
- 'orders_total_id' => $sQry->value('orders_total_id')
- , 'orders_id' => $sQry->value('orders_id')
- , 'title' => $sQry->value('title')
- , 'text' => $sQry->value('text')
- , 'value' => $sQry->value('value')
- , 'class' => $sQry->value('class')
- , 'sort_order' => $sQry->value('sort_order')
- );
-
- $tQry = $target_db->query('INSERT INTO :table_orders_total (orders_total_id,
- orders_id,
- title,
- text,
- value,
- class,
- sort_order)
- VALUES (:orders_total_id,
- :orders_id,
- :title,
- :text,
- :value,
- :class,
- :sort_order)');
-
- $tQry->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
- $tQry->bindInt (':orders_total_id', $order_total['orders_total_id']);
- $tQry->bindInt (':orders_id' , $order_total['orders_id']);
- $tQry->bindValue(':title' , $order_total['title']);
- $tQry->bindValue(':text' , $order_total['text']);
- $tQry->bindValue(':value' , $order_total['value']);
- $tQry->bindValue(':class' , $orders_total_map[$order_total['class']]);
- $tQry->bindInt (':sort_order' , $order_total['sort_order']);
- $tQry->execute();
-
- $cnt++;
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
- }
+ return true;
- $sQry->freeResult();
+ } // end importImages
+
+ /*
+ * function name : importCategoryImages()
+ *
+ * description : load category images from the source server to the new loaded7 server
+ *
+ * returns : true or false
+ *
+ */
+ public function importCategoryImages() {
+ global $lC_Language;
+
+ $source_img_dir = $this->_sDB['INSTALL_PATH'].$this->_sDB['IMAGE_PATH'];
+ $target_img_dir = getcwd() . '/../images/categories/';
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
}
- // END LOAD ORDERS TOTAL FROM SOURCE DB
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
- $orders_total = null;
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
- // END LOAD ORDERS TOTAL TO TARGET DB
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
- // ##########
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
- // LOAD ORDERS PRODUCTS DOWNLOAD FROM SOURCE DB
+ // END CONNNECT TO TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD category images FROM SOURCE DB
- $map = $this->_data_mapping['orders_products_download'];
- $orders_products_download = array();
+ $map = $this->_data_mapping['categories'];
- $sQry = $source_db->query('SELECT * FROM orders_products_download');
+ $source_categ_images = array();
+ $sQry = $source_db->query('SELECT * FROM categories ORDER BY categories_id');
$sQry->execute();
- $numrows= $sQry->numberOfRows();
- if ($numrows > 0) {
+ if ($sQry->numberOfRows() > 0) {
$cnt = 0;
while ($sQry->next()) {
- $orders_product_download = array(
- 'orders_products_download_id' => $sQry->value($map['orders_products_download_id'])
- , 'orders_id' => $sQry->value($map['orders_id'])
- , 'orders_products_id' => $sQry->value($map['orders_products_id'])
- , 'orders_products_filename' => $sQry->value($map['orders_products_filename'])
- , 'download_maxdays' => $sQry->value($map['download_maxdays'])
- , 'download_count' => $sQry->value($map['download_count'])
- );
-
- $tQry = $target_db->query('INSERT INTO :table_orders_products_download (orders_products_download_id,
- orders_id,
- orders_products_id,
- orders_products_filename,
- download_maxdays,
- download_count)
- VALUES (:orders_products_download_id,
- :orders_id,
- :orders_products_id,
- :orders_products_filename,
- :download_maxdays,
- :download_count)');
-
- $tQry->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
- $tQry->bindInt (':orders_products_download_id', $orders_product_download['orders_products_download_id']);
- $tQry->bindInt (':orders_id' , $orders_product_download['orders_id']);
- $tQry->bindInt (':orders_products_id' , $orders_product_download['orders_products_id']);
- $tQry->bindValue(':orders_products_filename' , $orders_product_download['orders_products_filename']);
- $tQry->bindInt (':download_maxdays' , $orders_product_download['download_maxdays']);
- $tQry->bindInt (':download_count' , $orders_product_download['download_count']);
- $tQry->execute();
+ if (!file_exists($source_img_dir . $sQry->value($map['categories_image'])) ||
+ !is_readable($source_img_dir . $sQry->value($map['categories_image']))
+ ) {
+ continue;
+ }
+
+ $images_info = array(
+ 'categories_id' => $sQry->value($map['categories_id'])
+ , 'categories_image' => $sQry->value($map['categories_image'])
+ );
+
+ $source_categ_images[] = $images_info;
$cnt++;
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
}
$sQry->freeResult();
}
- // END LOAD PRODUCTS DOWNLOAD FROM SOURCE DB
-
- $orders_products_download = null;
+ // END LOAD category images FROM SOURCE DB
- // END LOAD ORDERS PRODUCTS DOWNLOAD TO TARGET DB
+ // COPY category images TO TARGET SERVER
- // ##########
+ foreach ($source_categ_images as $image) {
- // LOAD ORDERS FROM SOURCE DB
+ $img_info = $image['categories_image'];
+
+ if (empty($img_info)) continue;
+
+ // if not exist, loop to next ;
+ if (!file_exists($source_img_dir.$img_info) ||
+ !is_readable($source_img_dir.$img_info)
+ ) {
+ continue;
+ }
+ $to_zip[] = $img_info;
+
+ }
- $map = $this->_data_mapping['orders'];
- $orders = array();
+ $o_dir = getcwd();
+ chdir($source_img_dir);
+ $target_zip = 'my-category-images-' . time() . '.zip';
- $sQry = $source_db->query('SELECT o.*, o.ipaddy as customers_ip_address, o.customers_address_format_id AS customers_address_format, o.billing_address_format_id AS billing_address_format, o.delivery_address_format_id AS delivery_address_format, c.countries_iso_code_2 AS customers_country_iso2, c.countries_iso_code_3 AS customers_country_iso3, z.zone_code AS customers_state_code, zz.zone_code AS delivery_state_code, cc.countries_iso_code_2 AS delivery_country_iso2, cc.countries_iso_code_3 AS delivery_country_iso3, zzz.zone_code AS billing_state_code, ccc.countries_iso_code_2 AS billing_country_iso2, ccc.countries_iso_code_3 AS billing_country_iso3 FROM orders o LEFT JOIN countries c ON o.customers_country = c.countries_name LEFT JOIN countries cc ON o.delivery_country = cc.countries_name LEFT JOIN countries ccc ON o.billing_country = ccc.countries_name LEFT JOIN zones z ON o.customers_state = z.zone_name LEFT JOIN zones zz ON o.delivery_state = zz.zone_name LEFT JOIN zones zzz ON o.billing_state = zzz.zone_name');
- $sQry->execute();
+ $result = $this->create_zip($to_zip, $target_img_dir . $target_zip);
+ if ($result == false) {
+ $this->_msg = $lC_Language->get('upgrade_step4_import_category_images_zipcreateerror');
+ return false;
+ }
+
+ $result = $this->extract_zip($target_img_dir . $target_zip, $target_img_dir);
+ if ($result == false) {
+ $this->_msg = $lC_Language->get('upgrade_step4_import_category_images_zipextracterror');
+ return false;
+ }
+
+ unlink($target_img_dir . $target_zip);
+ $this->chmod_r($target_img_dir);
+ chdir($o_dir);
+
+ // END COPY category images TO TARGET SERVER
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
- if (!isset($pending_id) || $pending_id == null || $pending_id == '') $pending_id = 1;
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
- $numrows= $sQry->numberOfRows();
- if ($numrows > 0) {
- $cnt = 0;
- while ($sQry->next()) {
- $order = array(
- 'orders_id' => $sQry->value($map['orders_id'])
- , 'customers_id' => $sQry->value($map['customers_id'])
- , 'customers_name' => $sQry->value($map['customers_name'])
- , 'customers_company' => $sQry->value($map['customers_company'])
- , 'customers_street_address' => $sQry->value($map['customers_street_address'])
- , 'customers_suburb' => $sQry->value($map['customers_suburb'])
- , 'customers_city' => $sQry->value($map['customers_city'])
- , 'customers_postcode' => $sQry->value($map['customers_postcode'])
- , 'customers_state' => $sQry->value($map['customers_state'])
- , 'customers_state_code' => $sQry->value($map['customers_state_code'])
- , 'customers_country' => $sQry->value($map['customers_country'])
- , 'customers_country_iso2' => $sQry->value($map['customers_country_iso2'])
- , 'customers_country_iso3' => $sQry->value($map['customers_country_iso3'])
- , 'customers_telephone' => $sQry->value($map['customers_telephone'])
- , 'customers_email_address' => $sQry->value($map['customers_email_address'])
- , 'customers_address_format' => self::getAddressFormat($sQry->value($map['customers_country']))
- , 'customers_ip_address' => $sQry->value($map['customers_ip_address'])
- , 'delivery_name' => $sQry->value($map['delivery_name'])
- , 'delivery_company' => $sQry->value($map['delivery_company'])
- , 'delivery_street_address' => $sQry->value($map['delivery_street_address'])
- , 'delivery_suburb' => $sQry->value($map['delivery_suburb'])
- , 'delivery_city' => $sQry->value($map['delivery_city'])
- , 'delivery_postcode' => $sQry->value($map['delivery_postcode'])
- , 'delivery_state' => $sQry->value($map['delivery_state'])
- , 'delivery_state_code' => $sQry->value($map['delivery_state_code'])
- , 'delivery_country' => $sQry->value($map['delivery_country'])
- , 'delivery_country_iso2' => $sQry->value($map['delivery_country_iso2'])
- , 'delivery_country_iso3' => $sQry->value($map['delivery_country_iso3'])
- , 'delivery_address_format' => self::getAddressFormat($sQry->value($map['delivery_country']))
- , 'billing_name' => $sQry->value($map['billing_name'])
- , 'billing_company' => $sQry->value($map['billing_company'])
- , 'billing_street_address' => $sQry->value($map['billing_street_address'])
- , 'billing_suburb' => $sQry->value($map['billing_suburb'])
- , 'billing_city' => $sQry->value($map['billing_city'])
- , 'billing_postcode' => $sQry->value($map['billing_postcode'])
- , 'billing_state' => $sQry->value($map['billing_state'])
- , 'billing_state_code' => $sQry->value($map['billing_state_code'])
- , 'billing_country' => $sQry->value($map['billing_country'])
- , 'billing_country_iso2' => $sQry->value($map['billing_country_iso2'])
- , 'billing_country_iso3' => $sQry->value($map['billing_country_iso3'])
- , 'billing_address_format' => self::getAddressFormat($sQry->value($map['billing_country']))
- , 'payment_method' => $sQry->value($map['payment_method'])
- , 'payment_module' => $sQry->value($map['payment_info'])
- , 'last_modified' => $sQry->value($map['last_modified'])
- , 'date_purchased' => $sQry->value($map['date_purchased'])
- , 'orders_status' => $sQry->value($map['orders_status'])
- , 'orders_date_finished' => $sQry->value($map['orders_date_finished'])
- , 'currency' => $sQry->value($map['currency'])
- , 'currency_value' => $sQry->value($map['currency_value'])
- );
-
- $tQry = $target_db->query('INSERT INTO :table_orders (orders_id,
+ } // end importCategoryImages
+
+ public function saveToProductsImages($target_db, $pid, $image, $sort, $default_flag = 1) {
+
+ $image = end(explode('/', $image));
+
+ $tQry = $target_db->query('INSERT INTO :table_products_images (products_id,
+ image,
+ default_flag,
+ sort_order)
+ VALUES (:products_id,
+ :image,
+ :default_flag,
+ :sort_order)');
+
+ $tQry->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
+ $tQry->bindInt (':products_id' , $pid);
+ $tQry->bindValue(':image' , $image);
+ $tQry->bindInt (':default_flag', $default_flag);
+ $tQry->bindInt (':sort_order' , $sort);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ return true;
+
+ } // end saveToProductsImages
+
+ /*
+ * function name : importCustomerGroups()
+ *
+ * description : load customer group data from source to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importCustomerGroups($switch = null) {
+ global $lC_Language;
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+ $map = $this->_data_mapping['customers_groups'];
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // LOAD CUSTOMERS GROUPS FROM SOURCE DB
+
+ //$tQry = $target_db->query('SELECT COUNT(*) AS exist
+ // FROM information_schema.tables
+ // WHERE table_schema = "' . $t_db['DB_DATABASE'] . '"
+ // AND table_name = "' . TABLE_CUSTOMERS_GROUPS . '"');
+ //$tQry->execute();
+ //$tQry->next();
+ //if ($tQry->value('exist') != '1') return true;
+ //$tQry->freeResult();
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ $customers_groups = array();
+
+ $sQry = $source_db->query('SELECT * FROM customers_groups');
+ $sQry->execute();
+
+ if ($sQry->numberOfRows() > 0) {
+ // TRUNCATE CUSTOMERS GROUPS TABLES IN TARGET DB
+ $tQry = $target_db->query('truncate table ' . TABLE_CUSTOMERS_GROUPS);
+ $tQry->execute();
+
+ $cnt = 0;
+ while ($sQry->next()) {
+ $customers_group = array(
+ 'customers_group_id' => $sQry->value('customers_group_id')
+ , 'language_id' => 1
+ , 'customers_group_name' => $sQry->value('customers_group_name')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_customers_groups (customers_group_id,
+ language_id,
+ customers_group_name)
+ VALUES (:customers_group_id,
+ :language_id,
+ :customers_group_name)');
+
+ $tQry->bindTable(':table_customers_groups', TABLE_CUSTOMERS_GROUPS);
+ $tQry->bindInt (':customers_group_id' , $customers_group['customers_group_id']);
+ $tQry->bindInt (':language_id' , $customers_group['language_id']);
+ $tQry->bindValue(':customers_group_name' , $customers_group['customers_group_name']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $customers_group_data = array(
+ 'customers_group_id' => $sQry->value('customers_group_id')
+ , 'baseline_discount' => $sQry->value('group_discount')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_customers_groups_data (customers_group_id,
+ baseline_discount)
+ VALUES (:customers_group_id,
+ :baseline_discount)');
+
+ $tQry->bindTable(':table_customers_groups_data', TABLE_CUSTOMERS_GROUPS_DATA);
+ $tQry->bindInt (':customers_group_id' , $customers_group_data['customers_group_id']);
+ $tQry->bindValue(':baseline_discount' , $customers_group_data['baseline_discount']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $cnt++;
+ }
+
+ $sQry->freeResult();
+
+ // get the lowest customers group id
+ $lidQry = $source_db->query("SELECT MIN(customers_group_id) AS customers_group_id FROM customers_groups");
+ $lidQry->execute();
+
+ // set default customers group to lowest resulting id in above query
+ $tQry = $target_db->query("UPDATE :table_configuration SET configuration_value = :configuration_value WHERE configuration_key = 'DEFAULT_CUSTOMERS_GROUP_ID'");
+ $tQry->bindTable(':table_configuration', TABLE_CONFIGURATION);
+ $tQry->bindInt(':configuration_value', $lidQry->value('customers_group_id'));
+ $tQry->execute();
+ }
+
+ // END LOAD CUSTOMERS GROUPS FROM SOURCE DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry->execute();
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importCustomerGroups
+
+ /*
+ * function name : importOrders()
+ *
+ * description : load orders from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrders($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // ##########
+
+ // TRUNCATE ORDERS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS TABLE IN TARGET DB
+
+ // ##########
+
+ // LOAD ORDERS FROM SOURCE DB
+
+ $map = $this->_data_mapping['orders'];
+ $orders = array();
+
+ $sQry = $source_db->query('SELECT DISTINCT o.*, o.ipaddy as customers_ip_address, o.customers_address_format_id AS customers_address_format, o.billing_address_format_id AS billing_address_format, o.delivery_address_format_id AS delivery_address_format, c.countries_iso_code_2 AS customers_country_iso2, c.countries_iso_code_3 AS customers_country_iso3, z.zone_code AS customers_state_code, zz.zone_code AS delivery_state_code, cc.countries_iso_code_2 AS delivery_country_iso2, cc.countries_iso_code_3 AS delivery_country_iso3, zzz.zone_code AS billing_state_code, ccc.countries_iso_code_2 AS billing_country_iso2, ccc.countries_iso_code_3 AS billing_country_iso3 FROM orders o LEFT JOIN countries c ON o.customers_country = c.countries_name LEFT JOIN countries cc ON o.delivery_country = cc.countries_name LEFT JOIN countries ccc ON o.billing_country = ccc.countries_name LEFT JOIN zones z ON o.customers_state = z.zone_name LEFT JOIN zones zz ON o.delivery_state = zz.zone_name LEFT JOIN zones zzz ON o.billing_state = zzz.zone_name');
+ $sQry->execute();
+
+ if (!isset($pending_id) || $pending_id == null || $pending_id == '') $pending_id = 1;
+
+ $numrows= $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $order = array(
+ 'orders_id' => $sQry->value($map['orders_id'])
+ , 'customers_id' => $sQry->value($map['customers_id'])
+ , 'customers_name' => $sQry->value($map['customers_name'])
+ , 'customers_company' => $sQry->value($map['customers_company'])
+ , 'customers_street_address' => $sQry->value($map['customers_street_address'])
+ , 'customers_suburb' => $sQry->value($map['customers_suburb'])
+ , 'customers_city' => $sQry->value($map['customers_city'])
+ , 'customers_postcode' => $sQry->value($map['customers_postcode'])
+ , 'customers_state' => $sQry->value($map['customers_state'])
+ , 'customers_state_code' => $sQry->value($map['customers_state_code'])
+ , 'customers_country' => $sQry->value($map['customers_country'])
+ , 'customers_country_iso2' => $sQry->value($map['customers_country_iso2'])
+ , 'customers_country_iso3' => $sQry->value($map['customers_country_iso3'])
+ , 'customers_telephone' => $sQry->value($map['customers_telephone'])
+ , 'customers_email_address' => $sQry->value($map['customers_email_address'])
+ , 'customers_address_format' => self::getAddressFormat($sQry->value($map['customers_country']))
+ , 'customers_ip_address' => $sQry->value($map['customers_ip_address'])
+ , 'delivery_name' => $sQry->value($map['delivery_name'])
+ , 'delivery_company' => $sQry->value($map['delivery_company'])
+ , 'delivery_street_address' => $sQry->value($map['delivery_street_address'])
+ , 'delivery_suburb' => $sQry->value($map['delivery_suburb'])
+ , 'delivery_city' => $sQry->value($map['delivery_city'])
+ , 'delivery_postcode' => $sQry->value($map['delivery_postcode'])
+ , 'delivery_state' => $sQry->value($map['delivery_state'])
+ , 'delivery_state_code' => $sQry->value($map['delivery_state_code'])
+ , 'delivery_country' => $sQry->value($map['delivery_country'])
+ , 'delivery_country_iso2' => $sQry->value($map['delivery_country_iso2'])
+ , 'delivery_country_iso3' => $sQry->value($map['delivery_country_iso3'])
+ , 'delivery_address_format' => self::getAddressFormat($sQry->value($map['delivery_country']))
+ , 'billing_name' => $sQry->value($map['billing_name'])
+ , 'billing_company' => $sQry->value($map['billing_company'])
+ , 'billing_street_address' => $sQry->value($map['billing_street_address'])
+ , 'billing_suburb' => $sQry->value($map['billing_suburb'])
+ , 'billing_city' => $sQry->value($map['billing_city'])
+ , 'billing_postcode' => $sQry->value($map['billing_postcode'])
+ , 'billing_state' => $sQry->value($map['billing_state'])
+ , 'billing_state_code' => $sQry->value($map['billing_state_code'])
+ , 'billing_country' => $sQry->value($map['billing_country'])
+ , 'billing_country_iso2' => $sQry->value($map['billing_country_iso2'])
+ , 'billing_country_iso3' => $sQry->value($map['billing_country_iso3'])
+ , 'billing_address_format' => self::getAddressFormat($sQry->value($map['billing_country']))
+ , 'payment_method' => $sQry->value($map['payment_method'])
+ , 'payment_module' => $sQry->value($map['payment_info'])
+ , 'last_modified' => $sQry->value($map['last_modified'])
+ , 'date_purchased' => $sQry->value($map['date_purchased'])
+ , 'orders_status' => $sQry->value($map['orders_status'])
+ , 'orders_date_finished' => $sQry->value($map['orders_date_finished'])
+ , 'currency' => $sQry->value($map['currency'])
+ , 'currency_value' => $sQry->value($map['currency_value'])
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_orders (orders_id,
customers_id,
customers_name,
customers_company,
@@ -3928,210 +4300,857 @@ class,
:orders_date_finished,
:currency, :currency_value)');
- $tQry->bindTable(':table_orders', TABLE_ORDERS);
- $tQry->bindInt (':orders_id' , $order['orders_id']);
- $tQry->bindInt (':customers_id' , $order['customers_id']);
- $tQry->bindValue(':customers_name' , $order['customers_name']);
- $tQry->bindValue(':customers_company' , $order['customers_company']);
- $tQry->bindValue(':customers_street_address', $order['customers_street_address']);
- $tQry->bindValue(':customers_suburb' , $order['customers_suburb']);
- $tQry->bindValue(':customers_city' , $order['customers_city']);
- $tQry->bindValue(':customers_postcode' , $order['customers_postcode']);
- $tQry->bindValue(':customers_state' , $order['customers_state']);
- $tQry->bindValue(':customers_state_code' , $order['customers_state_code']);
- $tQry->bindValue(':customers_country' , $order['customers_country']);
- $tQry->bindValue(':customers_country_iso2' , $order['customers_country_iso2']);
- $tQry->bindValue(':customers_country_iso3' , $order['customers_country_iso3']);
- $tQry->bindValue(':customers_telephone' , $order['customers_telephone']);
- $tQry->bindValue(':customers_email_address' , $order['customers_email_address']);
- $tQry->bindValue(':customers_address_format', $order['customers_address_format']);
- $tQry->bindValue(':customers_ip_address' , $order['customers_ip_address']);
- $tQry->bindValue(':delivery_name' , $order['delivery_name']);
- $tQry->bindValue(':delivery_company' , $order['delivery_company']);
- $tQry->bindValue(':delivery_street_address' , $order['delivery_street_address']);
- $tQry->bindValue(':delivery_suburb' , $order['delivery_suburb']);
- $tQry->bindValue(':delivery_city' , $order['delivery_city']);
- $tQry->bindValue(':delivery_postcode' , $order['delivery_postcode']);
- $tQry->bindValue(':delivery_state' , $order['delivery_state']);
- $tQry->bindValue(':delivery_state_code' , $order['delivery_state_code']);
- $tQry->bindValue(':delivery_country' , $order['delivery_country']);
- $tQry->bindValue(':delivery_country_iso2' , $order['delivery_country_iso2']);
- $tQry->bindValue(':delivery_country_iso3' , $order['delivery_country_iso3']);
- $tQry->bindValue(':delivery_address_format' , $order['delivery_address_format']);
- $tQry->bindValue(':billing_name' , $order['billing_name']);
- $tQry->bindValue(':billing_company' , $order['billing_company']);
- $tQry->bindValue(':billing_street_address' , $order['billing_street_address']);
- $tQry->bindValue(':billing_suburb' , $order['billing_suburb']);
- $tQry->bindValue(':billing_city' , $order['billing_city']);
- $tQry->bindValue(':billing_postcode' , $order['billing_postcode']);
- $tQry->bindValue(':billing_state' , $order['billing_state']);
- $tQry->bindValue(':billing_state_code' , $order['billing_state_code']);
- $tQry->bindValue(':billing_country' , $order['billing_country']);
- $tQry->bindValue(':billing_country_iso2' , $order['billing_country_iso2']);
- $tQry->bindValue(':billing_country_iso3' , $order['billing_country_iso3']);
- $tQry->bindValue(':billing_address_format' , $order['billing_address_format']);
- $tQry->bindValue(':payment_method' , $order['payment_method']);
- $tQry->bindValue(':payment_module' , $order['payment_info']);
- $tQry->bindValue(':last_modified' , $order['last_modified']);
- $tQry->bindValue(':date_purchased' , $order['date_purchased']);
- $tQry->bindInt (':orders_status' , ($order['orders_status'] == 0) ? $pending_id : $order['orders_status']);
- $tQry->bindValue(':orders_date_finished' , ($order['orders_date_finished'] != NULL) ? $order['orders_date_finished'] : '0000-00-00 00:00:00');
- $tQry->bindValue(':currency' , $order['currency']);
- $tQry->bindFloat(':currency_value' , $order['currency_value']);
+ $tQry->bindTable(':table_orders' , TABLE_ORDERS);
+ $tQry->bindInt (':orders_id' , $order['orders_id']);
+ $tQry->bindInt (':customers_id' , $order['customers_id']);
+ $tQry->bindValue(':customers_name' , $order['customers_name']);
+ $tQry->bindValue(':customers_company' , $order['customers_company']);
+ $tQry->bindValue(':customers_street_address', $order['customers_street_address']);
+ $tQry->bindValue(':customers_suburb' , $order['customers_suburb']);
+ $tQry->bindValue(':customers_city' , $order['customers_city']);
+ $tQry->bindValue(':customers_postcode' , $order['customers_postcode']);
+ $tQry->bindValue(':customers_state' , $order['customers_state']);
+ $tQry->bindValue(':customers_state_code' , $order['customers_state_code']);
+ $tQry->bindValue(':customers_country' , $order['customers_country']);
+ $tQry->bindValue(':customers_country_iso2' , $order['customers_country_iso2']);
+ $tQry->bindValue(':customers_country_iso3' , $order['customers_country_iso3']);
+ $tQry->bindValue(':customers_telephone' , $order['customers_telephone']);
+ $tQry->bindValue(':customers_email_address' , $order['customers_email_address']);
+ $tQry->bindValue(':customers_address_format', $order['customers_address_format']);
+ $tQry->bindValue(':customers_ip_address' , $order['customers_ip_address']);
+ $tQry->bindValue(':delivery_name' , $order['delivery_name']);
+ $tQry->bindValue(':delivery_company' , $order['delivery_company']);
+ $tQry->bindValue(':delivery_street_address' , $order['delivery_street_address']);
+ $tQry->bindValue(':delivery_suburb' , $order['delivery_suburb']);
+ $tQry->bindValue(':delivery_city' , $order['delivery_city']);
+ $tQry->bindValue(':delivery_postcode' , $order['delivery_postcode']);
+ $tQry->bindValue(':delivery_state' , $order['delivery_state']);
+ $tQry->bindValue(':delivery_state_code' , $order['delivery_state_code']);
+ $tQry->bindValue(':delivery_country' , $order['delivery_country']);
+ $tQry->bindValue(':delivery_country_iso2' , $order['delivery_country_iso2']);
+ $tQry->bindValue(':delivery_country_iso3' , $order['delivery_country_iso3']);
+ $tQry->bindValue(':delivery_address_format' , $order['delivery_address_format']);
+ $tQry->bindValue(':billing_name' , $order['billing_name']);
+ $tQry->bindValue(':billing_company' , $order['billing_company']);
+ $tQry->bindValue(':billing_street_address' , $order['billing_street_address']);
+ $tQry->bindValue(':billing_suburb' , $order['billing_suburb']);
+ $tQry->bindValue(':billing_city' , $order['billing_city']);
+ $tQry->bindValue(':billing_postcode' , $order['billing_postcode']);
+ $tQry->bindValue(':billing_state' , $order['billing_state']);
+ $tQry->bindValue(':billing_state_code' , $order['billing_state_code']);
+ $tQry->bindValue(':billing_country' , $order['billing_country']);
+ $tQry->bindValue(':billing_country_iso2' , $order['billing_country_iso2']);
+ $tQry->bindValue(':billing_country_iso3' , $order['billing_country_iso3']);
+ $tQry->bindValue(':billing_address_format' , $order['billing_address_format']);
+ $tQry->bindValue(':payment_method' , $order['payment_method']);
+ $tQry->bindValue(':payment_module' , $order['payment_info']);
+ $tQry->bindValue(':last_modified' , $order['last_modified']);
+ $tQry->bindValue(':date_purchased' , $order['date_purchased']);
+ $tQry->bindInt (':orders_status' , ($order['orders_status'] == 0) ? $pending_id : $order['orders_status']);
+ $tQry->bindValue(':orders_date_finished' , ($order['orders_date_finished'] != NULL) ? $order['orders_date_finished'] : '0000-00-00 00:00:00');
+ $tQry->bindValue(':currency' , $order['currency']);
+ $tQry->bindFloat(':currency_value' , $order['currency_value']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $cnt++;
+
+ // added to check for orders status id of 0 and adjust new db values to avoid errors
+ if ($order['orders_status'] == 0) {
+ $osQry = $target_db->query("SELECT * FROM :table_orders_status_history WHERE orders_id = " . $order['orders_id']);
+ $osQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
+ $osQry->execute();
+
+ $numrows = $osQry->numberOfRows();
+ if ($numrows < 1) {
+ $osQry = $target_db->query("INSERT INTO :table_orders_status_history (orders_id, orders_status_id) VALUES (:orders_id, :orders_status_id)");
+ $osQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
+ $osQry->bindInt (':orders_id' , $order['orders_id']);
+ $osQry->bindInt (':orders_status_id' , $pending_id);
+ $osQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+ }
+ }
+
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD ORDERS FROM SOURCE DB
+
+ $order = null;
+
+ // ##########
+
+ // END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // ##########
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importOrders
+
+ /*
+ * function name : importOrdersProducts()
+ *
+ * description : load orders_products from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrdersProducts($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // ##########
+
+ // TRUNCATE ORDERS PRODUCTS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_PRODUCTS);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS PRODUCTS TABLE IN TARGET DB
+
+ // ##########
+
+ // LOAD ORDERS PRODUCTS FROM SOURCE DB
+
+ $map = $this->_data_mapping['orders_products'];
+ $orders_products = array();
+
+ $sQry = $source_db->query('SELECT o.orders_products_id, o.orders_id, o.products_id, o.products_model, o.products_name, o.products_price, o.products_tax, o.products_quantity FROM orders_products AS o');
+ $sQry->execute();
+
+ $numrows= $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $orders_products_id = $sQry->value($map['orders_products_id']);
+
+ // ADDED FOR ORDERS SIMPLE OPTIONS META DATA FIX
+
+ $products_simple_options_meta_data = array();
+
+ $mdQry = $source_db->query('SELECT * FROM orders_products_attributes WHERE orders_products_id = :orders_products_id');
+ $mdQry->bindInt(':orders_products_id', $orders_products_id);
+ $mdQry->execute();
+
+ if ($mdQry->numberOfRows() > 0) {
+ while ($mdQry->next()) {
+ $vQry = $source_db->query('SELECT products_options_values_id FROM products_options_values WHERE products_options_values_name LIKE :products_options_values_name LIMIT 1');
+ $vQry->bindValue(':products_options_values_name', '%' . $mdQry->value('products_options') . '%');
+ $vQry->execute();
+
+ $oQry = $source_db->query('SELECT products_options_text_id FROM products_options_text WHERE products_options_name LIKE :products_options_name LIMIT 1');
+ $oQry->bindValue(':products_options_name', '%' . $mdQry->value('products_options') . '%');
+ $oQry->execute();
+
+ $modifier = ($mdQry->value('price_prefix') == '+' ? 1 : -1);
+
+ $products_simple_options_meta_data[] = array('value_id' => $vQry->valueInt('products_options_values_id'),
+ 'group_id' => $oQry->valueInt('products_options_text_id'),
+ 'group_title' => $mdQry->value('products_options'),
+ 'value_title' => $mdQry->value('products_options_values'),
+ 'price_modifier' => (($mdQry->valueDecimal('options_values_price') * $modifier < 0) ? 0 : $mdQry->valueDecimal('options_values_price') * $modifier));
+
+
+
+
+ $vQry->freeResult();
+ $oQry->freeResult();
+ }
+ }
+
+ // END ADDED FOR ORDERS SIMPLE OPTIONS META DATA FIX
+
+ $orders_product = array(
+ 'orders_products_id' => $orders_products_id
+ , 'orders_id' => $sQry->value($map['orders_id'])
+ , 'products_id' => $sQry->value($map['products_id'])
+ , 'products_model' => $sQry->value($map['products_model'])
+ , 'products_name' => $sQry->value($map['products_name'])
+ , 'products_price' => $sQry->value($map['products_price'])
+ , 'products_tax' => $sQry->value($map['products_tax'])
+ , 'products_quantity' => $sQry->value($map['products_quantity'])
+ , 'products_simple_options_meta_data' => serialize($products_simple_options_meta_data)
+ );
+
+ $mdQry->freeResult();
+ $products_simple_options_meta_data = null;
+
+ $tQry = $target_db->query('INSERT INTO :table_orders_products (orders_products_id,
+ orders_id,
+ products_id,
+ products_model,
+ products_name,
+ products_price,
+ products_tax,
+ products_quantity,
+ products_simple_options_meta_data)
+ VALUES (:orders_products_id,
+ :orders_id,
+ :products_id,
+ :products_model,
+ :products_name,
+ :products_price,
+ :products_tax,
+ :products_quantity,
+ :products_simple_options_meta_data)');
+
+ $tQry->bindTable(':table_orders_products' , TABLE_ORDERS_PRODUCTS);
+ $tQry->bindInt (':orders_products_id' , $orders_product['orders_products_id']);
+ $tQry->bindInt (':orders_id' , $orders_product['orders_id']);
+ $tQry->bindInt (':products_id' , $orders_product['products_id']);
+ $tQry->bindValue(':products_model' , $orders_product['products_model']);
+ $tQry->bindValue(':products_name' , $orders_product['products_name']);
+ $tQry->bindValue(':products_price' , $orders_product['products_price']);
+ $tQry->bindValue(':products_tax' , $orders_product['products_tax']);
+ $tQry->bindValue(':products_quantity' , $orders_product['products_quantity']);
+ $tQry->bindValue(':products_simple_options_meta_data', $orders_product['products_simple_options_meta_data']);
+ $tQry->execute();
+
+ $cnt++;
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD ORDERS PRODUCTS FROM SOURCE DB
+
+ $orders_product = null;
+
+ // ##########
+
+ // END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // ##########
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importOrdersProducts
+
+ /*
+ * function name : importOrdersProductsDownload()
+ *
+ * description : load orders_products_download from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrdersProductsDownload($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // ##########
+
+ // TRUNCATE ORDERS PRODUCTS DOWNLOAD TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS PRODUCTS DOWNLOAD TABLE IN TARGET DB
+
+ // ##########
+
+ // LOAD ORDERS PRODUCTS DOWNLOAD FROM SOURCE DB
+
+ $map = $this->_data_mapping['orders_products_download'];
+ $orders_products_download = array();
+
+ $sQry = $source_db->query('SELECT * FROM orders_products_download');
+ $sQry->execute();
+
+ $numrows= $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $orders_product_download = array(
+ 'orders_products_download_id' => $sQry->value($map['orders_products_download_id'])
+ , 'orders_id' => $sQry->value($map['orders_id'])
+ , 'orders_products_id' => $sQry->value($map['orders_products_id'])
+ , 'orders_products_filename' => $sQry->value($map['orders_products_filename'])
+ , 'download_maxdays' => $sQry->value($map['download_maxdays'])
+ , 'download_count' => $sQry->value($map['download_count'])
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_orders_products_download (orders_products_download_id,
+ orders_id,
+ orders_products_id,
+ orders_products_filename,
+ download_maxdays,
+ download_count)
+ VALUES (:orders_products_download_id,
+ :orders_id,
+ :orders_products_id,
+ :orders_products_filename,
+ :download_maxdays,
+ :download_count)');
+
+ $tQry->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
+ $tQry->bindInt (':orders_products_download_id' , $orders_product_download['orders_products_download_id']);
+ $tQry->bindInt (':orders_id' , $orders_product_download['orders_id']);
+ $tQry->bindInt (':orders_products_id' , $orders_product_download['orders_products_id']);
+ $tQry->bindValue(':orders_products_filename' , $orders_product_download['orders_products_filename']);
+ $tQry->bindInt (':download_maxdays' , $orders_product_download['download_maxdays']);
+ $tQry->bindInt (':download_count' , $orders_product_download['download_count']);
+ $tQry->execute();
+
+ $cnt++;
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD PRODUCTS DOWNLOAD FROM SOURCE DB
+
+ $orders_products_download = null;
+
+ // END LOAD ORDERS PRODUCTS DOWNLOAD TO TARGET DB
+
+ // ##########
+
+ // END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // ##########
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importOrdersProductsDownload
+
+ /*
+ * function name : importOrdersStatus()
+ *
+ * description : load orders_status from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrdersStatus($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // ##########
+
+ // TRUNCATE ORDERS STATUS TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_STATUS);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS STATUS TABLE IN TARGET DB
+
+ // ##########
+
+ // LOAD ORDERS STATUS FROM SOURCE DB
+
+ $map = $this->_data_mapping['orders_status'];
+ $orders_status = array();
+
+ $sQry = $source_db->query('SELECT * FROM orders_status');
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ if ($sQry->value($map['language_id']) == $this->_languages_id_default && $sQry->value($map['orders_status_name']) == 'Pending') {
+ $pending_id = $sQry->value($map['orders_status_id']);
+ }
+ $orders_stat = array(
+ 'orders_status_id' => $sQry->value($map['orders_status_id'])
+ , 'language_id' => $sQry->value($map['language_id'])
+ , 'orders_status_name' => $sQry->value($map['orders_status_name'])
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_orders_status (orders_status_id,
+ language_id,
+ orders_status_name)
+ VALUES (:orders_status_id,
+ :language_id,
+ :orders_status_name)');
+
+ $tQry->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
+ $tQry->bindInt (':orders_status_id' , $orders_stat['orders_status_id']);
+ $tQry->bindInt (':language_id' , $orders_stat['language_id']);
+ $tQry->bindValue(':orders_status_name' , $orders_stat['orders_status_name']);
$tQry->execute();
+ $cnt++;
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD ORDERS STATUS FROM SOURCE DB
+
+ $orders_stat = null;
+
+ // ##########
+
+ // END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // ##########
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importOrdersStatus
+
+ /*
+ * function name : importOrdersStatusHistory()
+ *
+ * description : load orders_status_history from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrdersStatusHistory($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // ##########
+
+ // TRUNCATE ORDERS STATUS HISTORY TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_STATUS_HISTORY);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS STATUS HISTORY TABLE IN TARGET DB
+
+ // ##########
+
+ // LOAD ORDERS STATUS HISTORY FROM SOURCE DB
+
+ $map = $this->_data_mapping['orders_status_history'];
+ $orders_status_histories = array();
+
+ $sQry = $source_db->query('SELECT * FROM orders_status_history');
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $orders_status_history = array(
+ 'orders_status_history_id' => $sQry->value($map['orders_status_history_id'])
+ , 'orders_id' => $sQry->value($map['orders_id'])
+ , 'orders_status_id' => $sQry->value($map['orders_status_id'])
+ , 'date_added' => $sQry->value($map['date_added'])
+ , 'customer_notified' => $sQry->value($map['customer_notified'])
+ , 'comments' => $sQry->value($map['comments'])
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_orders_status_history (orders_status_history_id,
+ orders_id,
+ orders_status_id,
+ date_added,
+ customer_notified,
+ comments)
+ VALUES (:orders_status_history_id,
+ :orders_id,
+ :orders_status_id,
+ :date_added,
+ :customer_notified,
+ :comments)');
+ $tQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
+ $tQry->bindInt (':orders_status_history_id' , $orders_status_history['orders_status_history_id']);
+ $tQry->bindInt (':orders_id' , $orders_status_history['orders_id']);
+ $tQry->bindInt (':orders_status_id' , $orders_status_history['orders_status_id']);
+ $tQry->bindValue(':date_added' , $orders_status_history['date_added']);
+ $tQry->bindInt (':customer_notified' , $orders_status_history['customer_notified']);
+ $tQry->bindValue(':comments' , $orders_status_history['comments']);
+ $tQry->execute();
+
$cnt++;
- // added to check for orders status id of 0 and adjust new db values to avoid errors
- if ($order['orders_status'] == 0) {
- $osQry = $target_db->query("SELECT * FROM :table_orders_status_history WHERE orders_id = " . $order['orders_id']);
- $osQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
- $osQry->execute();
-
- $numrows = $osQry->numberOfRows();
- if ($numrows < 1) {
- $osQry = $target_db->query("INSERT INTO :table_orders_status_history (orders_id, orders_status_id) VALUES (:orders_id, :orders_status_id)");
- $osQry->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
- $osQry->bindInt (':orders_id' , $order['orders_id']);
- $osQry->bindInt (':orders_status_id' , $pending_id);
- $osQry->execute();
-
- if ($target_db->isError()) {
- $this->_msg = $target_db->getError();
- return false;
- }
- }
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD ORDERS STATUS HISTORY FROM SOURCE DB
+
+ $orders_status_history = null;
+
+ // ##########
+
+ // END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = ""');
+ $tQry->execute();
+
+ // ##########
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importOrdersStatusHistory
+
+ /*
+ * function name : importOrdersTotal()
+ *
+ * description : load orders_total from the source database to the new loaded7 database
+ *
+ * returns : true or false
+ *
+ */
+ public function importOrdersTotal($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
- }
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
- $sQry->freeResult();
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
}
+
+ // END CONNNECT TO TARGET DB
+
+ // ##########
- // END LOAD ORDERS FROM SOURCE DB
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET GLOBAL sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
- $order = null;
+ // ##########
+
+ // TRUNCATE ORDERS TOTAL TABLE IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_ORDERS_TOTAL);
+ $tQry->execute();
+
+ // END TRUNCATE ORDERS TOTAL TABLE IN TARGET DB
// ##########
- // LOAD ORDERS PRODUCTS FROM SOURCE DB
+ // LOAD ORDERS TOTAL FROM SOURCE DB
- $map = $this->_data_mapping['orders_products'];
- $orders_products = array();
+ $map = $this->_data_mapping['orders_total'];
+ $orders_total = array();
- $sQry = $source_db->query('SELECT o.orders_products_id, o.orders_id, o.products_id, o.products_model, o.products_name, o.products_price, o.products_tax, o.products_quantity FROM orders_products AS o');
+ $sQry = $source_db->query('SELECT * FROM orders_total');
$sQry->execute();
-
+
+ $orders_total_map = array(
+ 'ot_coupon' => 'coupon'
+ , 'ot_shipping' => 'shipping'
+ , 'ot_tax' => 'tax'
+ , 'ot_subtotal' => 'subtotal'
+ , 'ot_total' => 'total'
+ , 'xxxxxxxx' => 'low_order_fee'
+ );
+
$numrows= $sQry->numberOfRows();
if ($numrows > 0) {
$cnt = 0;
while ($sQry->next()) {
- $orders_products_id = $sQry->value($map['orders_products_id']);
-
- // ADDED FOR ORDERS SIMPLE OPTIONS META DATA FIX
-
- $products_simple_options_meta_data = array();
-
- $mdQry = $source_db->query('SELECT * FROM orders_products_attributes WHERE orders_products_id = :orders_products_id');
- $mdQry->bindInt(':orders_products_id', $orders_products_id);
- $mdQry->execute();
-
- if ($mdQry->numberOfRows() > 0) {
- while ($mdQry->next()) {
- $vQry = $source_db->query('SELECT products_options_values_id FROM products_options_values WHERE products_options_values_name LIKE :products_options_values_name LIMIT 1');
- $vQry->bindValue(':products_options_values_name', '%' . $mdQry->value('products_options') . '%');
- $vQry->execute();
-
- $oQry = $source_db->query('SELECT products_options_text_id FROM products_options_text WHERE products_options_name LIKE :products_options_name LIMIT 1');
- $oQry->bindValue(':products_options_name', '%' . $mdQry->value('products_options') . '%');
- $oQry->execute();
-
- $modifier = ($mdQry->value('price_prefix') == '+' ? 1 : -1);
-
- $products_simple_options_meta_data[] = array('value_id' => $vQry->valueInt('products_options_values_id'),
- 'group_id' => $oQry->valueInt('products_options_text_id'),
- 'group_title' => $mdQry->value('products_options'),
- 'value_title' => $mdQry->value('products_options_values'),
- 'price_modifier' => (($mdQry->valueDecimal('options_values_price') * $modifier < 0) ? 0 : $mdQry->valueDecimal('options_values_price') * $modifier));
-
-
-
-
- $vQry->freeResult();
- $oQry->freeResult();
- }
- }
-
- // END ADDED FOR ORDERS SIMPLE OPTIONS META DATA FIX
-
- $orders_product = array(
- 'orders_products_id' => $orders_products_id
- , 'orders_id' => $sQry->value($map['orders_id'])
- , 'products_id' => $sQry->value($map['products_id'])
- , 'products_model' => $sQry->value($map['products_model'])
- , 'products_name' => $sQry->value($map['products_name'])
- , 'products_price' => $sQry->value($map['products_price'])
- , 'products_tax' => $sQry->value($map['products_tax'])
- , 'products_quantity' => $sQry->value($map['products_quantity'])
- , 'products_simple_options_meta_data' => serialize($products_simple_options_meta_data)
- );
-
- $mdQry->freeResult();
- $products_simple_options_meta_data = null;
+ $order_total = array(
+ 'orders_total_id' => $sQry->value('orders_total_id')
+ , 'orders_id' => $sQry->value('orders_id')
+ , 'title' => $sQry->value('title')
+ , 'text' => $sQry->value('text')
+ , 'value' => $sQry->value('value')
+ , 'class' => $sQry->value('class')
+ , 'sort_order' => $sQry->value('sort_order')
+ );
- $tQry = $target_db->query('INSERT INTO :table_orders_products (orders_products_id,
- orders_id,
- products_id,
- products_model,
- products_name,
- products_price,
- products_tax,
- products_quantity,
- products_simple_options_meta_data)
- VALUES (:orders_products_id,
- :orders_id,
- :products_id,
- :products_model,
- :products_name,
- :products_price,
- :products_tax,
- :products_quantity,
- :products_simple_options_meta_data)');
+ $tQry = $target_db->query('INSERT INTO :table_orders_total (orders_total_id,
+ orders_id,
+ title,
+ text,
+ value,
+ class,
+ sort_order)
+ VALUES (:orders_total_id,
+ :orders_id,
+ :title,
+ :text,
+ :value,
+ :class,
+ :sort_order)');
- $tQry->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
- $tQry->bindInt (':orders_products_id' , $orders_product['orders_products_id']);
- $tQry->bindInt (':orders_id' , $orders_product['orders_id']);
- $tQry->bindInt (':products_id' , $orders_product['products_id']);
- $tQry->bindValue(':products_model' , $orders_product['products_model']);
- $tQry->bindValue(':products_name' , $orders_product['products_name']);
- $tQry->bindValue(':products_price' , $orders_product['products_price']);
- $tQry->bindValue(':products_tax' , $orders_product['products_tax']);
- $tQry->bindValue(':products_quantity' , $orders_product['products_quantity']);
- $tQry->bindValue(':products_simple_options_meta_data', $orders_product['products_simple_options_meta_data']);
+ $tQry->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
+ $tQry->bindInt (':orders_total_id' , $order_total['orders_total_id']);
+ $tQry->bindInt (':orders_id' , $order_total['orders_id']);
+ $tQry->bindValue(':title' , $order_total['title']);
+ $tQry->bindValue(':text' , $order_total['text']);
+ $tQry->bindValue(':value' , $order_total['value']);
+ $tQry->bindValue(':class' , $orders_total_map[$order_total['class']]);
+ $tQry->bindInt (':sort_order' , $order_total['sort_order']);
$tQry->execute();
-
+
$cnt++;
if ($target_db->isError()) {
$this->_msg = $target_db->getError();
return false;
}
-
}
$sQry->freeResult();
}
+
+ // END LOAD ORDERS TOTAL FROM SOURCE DB
- // END LOAD ORDERS PRODUCTS FROM SOURCE DB
+ $orders_total = null;
- $orders_product = null;
+ // END LOAD ORDERS TOTAL TO TARGET DB
- // ##########
+ // ##########
// END DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
$tQry = $target_db->query('SET GLOBAL sql_mode = ""');
@@ -4144,7 +5163,7 @@ class,
return true;
- } // end importOrders
+ } // end importOrdersTotal
/*
* function name : importAttributes()
@@ -4583,8 +5602,7 @@ public function importAttributes($switch = null) {
return true;
} // end importAttributes
-
-
+
/*
* function name : importAdministrators()
*
@@ -6477,6 +7495,131 @@ public function importCurrencies($switch = null) {
return true;
} // end importCurrencies
+
+ /*
+ * function name : importFeatured()
+ *
+ * description : load featured products to loaded7
+ *
+ * returns : true or false
+ *
+ */
+ public function importFeatured($switch = null) {
+
+ $s_db = $this->_sDB;
+ $t_db = $this->_tDB;
+ $map = $this->_data_mapping['featured'];
+
+ if (!defined('DB_TABLE_PREFIX')) define('DB_TABLE_PREFIX', $t_db['DB_PREFIX']);
+
+ // CONNNECT TO SOURCE DB
+
+ require_once('../includes/database_tables.php');
+
+ require_once('../includes/classes/database/mysqli.php');
+ $class = 'lC_Database_mysqli'; // . $s_db['DB_DATABASE_CLASS'];
+ $source_db = new $class($s_db['DB_SERVER'], $s_db['DB_SERVER_USERNAME'], $s_db['DB_SERVER_PASSWORD']);
+
+ if ($source_db->isError() === false) {
+ $source_db->selectDatabase($s_db['DB_DATABASE']);
+ }
+
+ if ($source_db->isError()) {
+ $this->_msg = $source_db->getError();
+ return false;
+ }
+ // END CONNNECT TO SOURCE DB
+
+ // CONNNECT TO TARGET DB
+
+ $class = 'lC_Database_' . $t_db['DB_CLASS'];
+ $target_db = new $class($t_db['DB_SERVER'], $t_db['DB_SERVER_USERNAME'], $t_db['DB_SERVER_PASSWORD']);
+
+ if ($target_db->isError() === false) {
+ $target_db->selectDatabase($t_db['DB_DATABASE']);
+ }
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ // END CONNNECT TO TARGET DB
+
+ // TRUNCATE FEATURED TABLES IN TARGET DB
+
+ $tQry = $target_db->query('truncate table ' . TABLE_FEATURED_PRODUCTS);
+ $tQry->execute();
+
+ // END TRUNCATE FEATURED TABLES IN TARGET DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = "NO_AUTO_VALUE_ON_ZERO"');
+ $tQry->execute();
+
+ // LOAD FEATURED FROM SOURCE DB
+
+ $sQry = $source_db->query('SELECT * FROM featured');
+ $sQry->execute();
+
+ $numrows = $sQry->numberOfRows();
+ if ($numrows > 0) {
+ $cnt = 0;
+ while ($sQry->next()) {
+ $featured = array(
+ 'id' => $sQry->value('featured_id')
+ , 'products_id' => $sQry->value('products_id')
+ , 'date_added' => $sQry->value('featured_date_added')
+ , 'last_modified' => $sQry->value('featured_last_modified')
+ , 'expires_date' => $sQry->value('expires_date')
+ , 'status' => $sQry->value('status')
+ );
+
+ $tQry = $target_db->query('INSERT INTO :table_featured (id,
+ products_id,
+ date_added,
+ last_modified,
+ expires_date,
+ status)
+ VALUES (:id,
+ :products_id,
+ :date_added,
+ :last_modified,
+ :expires_date,
+ :status)');
+
+ $tQry->bindTable(':table_featured', TABLE_FEATURED_PRODUCTS);
+ $tQry->bindInt (':id' , $featured['id']);
+ $tQry->bindInt (':products_id' , $featured['products_id']);
+ $tQry->bindDate (':date_added' , $featured['date_added']);
+ $tQry->bindDate (':last_modified' , $featured['last_modified']);
+ $tQry->bindDate (':expires_date' , $featured['expires_date']);
+ $tQry->bindInt (':status' , $featured['status']);
+ $tQry->execute();
+
+ if ($target_db->isError()) {
+ $this->_msg = $target_db->getError();
+ return false;
+ }
+
+ $cnt++;
+ }
+
+ $sQry->freeResult();
+ }
+
+ // END LOAD FEATURED FROM SOURCE DB
+
+ // DISABLE AUTO INCREMENT WHEN PRIMARY KEY = 0
+ $tQry = $target_db->query('SET sql_mode = ""');
+ $tQry->execute();
+
+ $source_db->disconnect();
+ $target_db->disconnect();
+
+ return true;
+
+ } // end importFeatured
public function generateCleanPermalink($p) {
$p = preg_replace("/&.{0,}?;/", '', $p);
@@ -6549,4 +7692,4 @@ public function getAddressFormat($name = null, $iso2 = null, $iso3 = null) {
return $address_format;
}
}
-?>
\ No newline at end of file
+?>
diff --git a/catalog/install/includes/languages/en_US/upgrade.php b/catalog/install/includes/languages/en_US/upgrade.php
index 9301b0506..77639259d 100644
--- a/catalog/install/includes/languages/en_US/upgrade.php
+++ b/catalog/install/includes/languages/en_US/upgrade.php
@@ -106,23 +106,68 @@
rpc_sqlfile_error = Cannot locate source configuration file
param_import_categories = CATEGORIES
-param_import_categories_description = importing Category data
+param_import_categories_description = importing Categories data
+
+param_import_categories_description = CATEGORIES DESCRIPTION
+param_import_categories_description_description = importing Categories Description data
param_import_products = PRODUCTS
-param_import_products_description = importing Product data
+param_import_products_description = importing Products data
+
+param_import_products_description = PRODUCTS DESCRIPTION
+param_import_products_description_description = importing Products Description data
+
+param_import_products_to_categories = PRODUCTS TO CATEGORIES
+param_import_products_to_categories_description = importing Products to Categories data
+
+param_import_products_notifications = PRODUCTS NOTIFICATIONS
+param_import_products_notifications_description = importing Products Notifications data
+
+param_import_featured = FEATURED PRODUCTS
+param_import_featured_description = importing Featured Products data
param_import_attributes = ATTRIBUTES
-param_import_attributes_description = importing Product Attributes data
+param_import_attributes_description = importing Attributes data
+
+param_import_manufacturers = MANUFACTURERS
+param_import_manufacturers_description = importing Manufacturers data
+
+param_import_manufacturers_info = MANUFACTURERS INFO
+param_import_manufacturers_info_description = importing Manufacturers Info data
+
+param_import_reviews = REVIEWS
+param_import_reviews_description = importing Reviews data
+
+param_import_specials = SPECIALS
+param_import_specials_description = importing Specials data
param_import_customers = CUSTOMERS
param_import_customers_description = importing Customer data
+param_import_address_book = ADDRESS BOOK
+param_import_address_book_description = importing Address Book data
+
param_import_customer_groups = CUSTOMER GROUPS
param_import_customer_groups_description = importing Customer Groups data
param_import_orders = ORDERS
param_import_orders_description = importing Orders data
+param_import_orders_products = ORDERS PRODUCTS
+param_import_orders_products_description = importing Orders Products data
+
+param_import_orders_products_download = ORDERS PRODUCTS DOWNLOAD
+param_import_orders_products_download_description = importing Orders Products Download data
+
+param_import_orders_status = ORDERS STATUS
+param_import_orders_status_description = importing Orders Status data
+
+param_import_orders_status_history = ORDERS STATUS HISTORY
+param_import_orders_status_history_description = importing Orders Status History data
+
+param_import_orders_total = ORDERS TOTAL
+param_import_orders_total_description = importing Orders Total data
+
param_import_cds = CONTENT DIRECTOR
param_import_cds_description = importing Content Director data
diff --git a/catalog/install/loadedcommerce.sql b/catalog/install/loadedcommerce.sql
index 4e7270596..a8a756282 100644
--- a/catalog/install/loadedcommerce.sql
+++ b/catalog/install/loadedcommerce.sql
@@ -326,7 +326,12 @@ CREATE TABLE lc_customers_groups_data (
id int(11) NOT NULL AUTO_INCREMENT,
customers_group_id int(11) NOT NULL DEFAULT '1',
baseline_discount decimal(5,2) NOT NULL DEFAULT '0.00',
- customers_access_levels VARCHAR(255) NOT NULL DEFAULT '',
+ customers_access_levels varchar(255) NOT NULL DEFAULT '',
+ payment_terms varchar(255) NOT NULL DEFAULT '',
+ hidden_products_notification tinyint(1) NOT NULL DEFAULT -1,
+ taxable tinyint(1) NOT NULL DEFAULT -1,
+ payment_modules varchar(255) NOT NULL DEFAULT '',
+ shipping_modules varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
@@ -383,6 +388,21 @@ CREATE TABLE lc_languages_definitions (
KEY IDX_LANGUAGES_DEFINITIONS_GROUPS (content_group)
) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
+DROP TABLE IF EXISTS lc_localization;
+CREATE TABLE IF NOT EXISTS lc_localization (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ domain varchar(255) NOT NULL,
+ alt_domain tinyint(1) NOT NULL DEFAULT '0',
+ currencies_id int(11) NOT NULL DEFAULT '0',
+ language_id int(11) NOT NULL DEFAULT '0',
+ show_tax tinyint(1) NOT NULL DEFAULT '0',
+ default_tax_zone int(11) NOT NULL DEFAULT '0',
+ base_price_modifier decimal(15,4) NOT NULL DEFAULT '0',
+ `status` tinyint(1) NOT NULL DEFAULT '1',
+ PRIMARY KEY (id)
+) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
+
+
DROP TABLE IF EXISTS lc_manufacturers;
CREATE TABLE lc_manufacturers (
manufacturers_id int(11) NOT NULL AUTO_INCREMENT,
@@ -622,6 +642,7 @@ CREATE TABLE lc_products (
groups_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
qpb_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
specials_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
+ products_sort_order int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (products_id),
KEY idx_products_date_added (products_date_added)
) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
@@ -1234,6 +1255,7 @@ INSERT INTO lc_configuration (configuration_id, configuration_title, configurati
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(189, 'Show Product Count', 'BOX_PRODUCT_CATEGORIES_SHOW_PRODUCT_COUNT', '-1', 'Show the amount of products each category has', '6', '0', now(), now(), 'lc_cfg_use_get_boolean_value', 'lc_cfg_set_boolean_value(array(1, -1))');
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(190, 'Top Category', 'BOX_PRODUCT_CATEGORIES_ROOT_CATEGORY', 1, 'Select the Top Category of the Product Categories Infobox', 6, 0, now(), now(), 'lc_cfg_set_categories_top_category(BOX_PRODUCT_CATEGORIES_ROOT_CATEGORY)', 'lc_cfg_set_categories_top_category');
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(191, 'Expand Menu Item', 'BOX_PRODUCT_CATEGORIES_MAX_LEVEL', 'All', 'How many levels to expand the category tree.', 6, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''None'', ''1'', ''2'', ''3'', ''All''))');
+INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(192, 'Products Display Order', 'PRODUCT_LISTING_DISPLAY_ORDER', 'Name', 'Products displayed on listing pages are ordered by this value.', 8, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''Name'', ''Model'', ''Price'', ''Manufacturer'', ''Quantity'', ''Weight'', ''Last Added'', ''Sort Order''))');
INSERT INTO lc_configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES(1, 'My Store', 'General information about my store', 1, 1);
INSERT INTO lc_configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES(2, 'Minimum Values', 'The minimum values for functions / data', 2, 1);
@@ -6226,6 +6248,9 @@ INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right
INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right, decimal_places, value, last_updated) VALUES(2, 'Euro', 'EUR', '€', '', '2', 0.726579, '2014-03-03 09:59:23');
INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right, decimal_places, value, last_updated) VALUES(3, 'British Pounds', 'GBP', '£', '', '2', 0.598311, '2014-03-03 09:59:23');
+INSERT INTO lc_customers_access (id, level, status) VALUES (1, 'Guest', 1);
+INSERT INTO lc_customers_access (id, level, status) VALUES (2, 'Registered', 1);
+
INSERT INTO lc_customers_groups (customers_group_id, language_id, customers_group_name) VALUES(1, 1, 'Registered');
INSERT INTO lc_customers_groups (customers_group_id, language_id, customers_group_name) VALUES(2, 1, 'Wholesale');
diff --git a/catalog/install/loadedcommerce_innodb.sql b/catalog/install/loadedcommerce_innodb.sql
index 09ff17412..6e8087c61 100644
--- a/catalog/install/loadedcommerce_innodb.sql
+++ b/catalog/install/loadedcommerce_innodb.sql
@@ -326,7 +326,12 @@ CREATE TABLE lc_customers_groups_data (
id int(11) NOT NULL AUTO_INCREMENT,
customers_group_id int(11) NOT NULL DEFAULT '1',
baseline_discount decimal(5,2) NOT NULL DEFAULT '0.00',
- customers_access_levels VARCHAR(255) NOT NULL DEFAULT '',
+ customers_access_levels varchar(255) NOT NULL DEFAULT '',
+ payment_terms varchar(255) NOT NULL DEFAULT '',
+ hidden_products_notification tinyint(1) NOT NULL DEFAULT -1,
+ taxable tinyint(1) NOT NULL DEFAULT -1,
+ payment_modules varchar(255) NOT NULL DEFAULT '',
+ shipping_modules varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
@@ -383,6 +388,20 @@ CREATE TABLE lc_languages_definitions (
KEY IDX_LANGUAGES_DEFINITIONS_GROUPS (content_group)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
+DROP TABLE IF EXISTS lc_localization;
+CREATE TABLE IF NOT EXISTS lc_localization (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ domain varchar(255) NOT NULL,
+ alt_domain tinyint(1) NOT NULL DEFAULT '0',
+ currencies_id int(11) NOT NULL DEFAULT '0',
+ language_id int(11) NOT NULL DEFAULT '0',
+ show_tax tinyint(1) NOT NULL DEFAULT '0',
+ default_tax_zone int(11) NOT NULL DEFAULT '0',
+ base_price_modifier decimal(15,4) NOT NULL DEFAULT '0',
+ `status` tinyint(1) NOT NULL DEFAULT '1',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
+
DROP TABLE IF EXISTS lc_manufacturers;
CREATE TABLE lc_manufacturers (
manufacturers_id int(11) NOT NULL AUTO_INCREMENT,
@@ -622,6 +641,7 @@ CREATE TABLE lc_products (
groups_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
qpb_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
specials_pricing_enable tinyint(1) NOT NULL DEFAULT '0',
+ products_sort_order int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (products_id),
KEY idx_products_date_added (products_date_added)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
@@ -1234,6 +1254,7 @@ INSERT INTO lc_configuration (configuration_id, configuration_title, configurati
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(189, 'Show Product Count', 'BOX_PRODUCT_CATEGORIES_SHOW_PRODUCT_COUNT', '-1', 'Show the amount of products each category has', '6', '0', now(), now(), 'lc_cfg_use_get_boolean_value', 'lc_cfg_set_boolean_value(array(1, -1))');
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(190, 'Top Category', 'BOX_PRODUCT_CATEGORIES_ROOT_CATEGORY', 1, 'Select the Top Category of the Product Categories Infobox', 6, 0, now(), now(), 'lc_cfg_set_categories_top_category(BOX_PRODUCT_CATEGORIES_ROOT_CATEGORY)', 'lc_cfg_set_categories_top_category');
INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(191, 'Expand Menu Item', 'BOX_PRODUCT_CATEGORIES_MAX_LEVEL', 'All', 'How many levels to expand the category tree.', 6, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''None'', ''1'', ''2'', ''3'', ''All''))');
+INSERT INTO lc_configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES(192, 'Products Display Order', 'PRODUCT_LISTING_DISPLAY_ORDER', 'Name', 'Products displayed on listing pages are ordered by this value.', 8, 0, now(), now(), null, 'lc_cfg_set_boolean_value(array(''Name'', ''Model'', ''Price'', ''Manufacturer'', ''Quantity'', ''Weight'', ''Last Added'', ''Sort Order''))');
INSERT INTO lc_configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES(1, 'My Store', 'General information about my store', 1, 1);
INSERT INTO lc_configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES(2, 'Minimum Values', 'The minimum values for functions / data', 2, 1);
@@ -6226,6 +6247,9 @@ INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right
INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right, decimal_places, value, last_updated) VALUES(2, 'Euro', 'EUR', '€', '', '2', 0.726579, '2014-03-03 09:59:23');
INSERT INTO lc_currencies (currencies_id, title, code, symbol_left, symbol_right, decimal_places, value, last_updated) VALUES(3, 'British Pounds', 'GBP', '£', '', '2', 0.598311, '2014-03-03 09:59:23');
+INSERT INTO lc_customers_access (id, level, status) VALUES (1, 'Guest', 1);
+INSERT INTO lc_customers_access (id, level, status) VALUES (2, 'Registered', 1);
+
INSERT INTO lc_customers_groups (customers_group_id, language_id, customers_group_name) VALUES(1, 1, 'Registered');
INSERT INTO lc_customers_groups (customers_group_id, language_id, customers_group_name) VALUES(2, 1, 'Wholesale');
diff --git a/catalog/install/rpc.php b/catalog/install/rpc.php
index ee68cddcb..1c2f46bf6 100644
--- a/catalog/install/rpc.php
+++ b/catalog/install/rpc.php
@@ -372,6 +372,24 @@
exit;
break;
+ case 'import_categories_description':
+ {
+
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importCategoriesDescription($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return false;
+ }
+ exit;
+ break;
+
case 'import_customers':
{
@@ -390,6 +408,24 @@
exit;
break;
+ case 'import_address_book':
+ {
+
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importAddressBook($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
case 'import_customer_groups':
{
require_once("includes/classes/upgrader.php");
@@ -411,53 +447,293 @@
case 'import_products':
{
- require_once("includes/classes/upgrader.php");
- $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
- $upgrader->setConnectDetails($_POST);
- $rslt = $upgrader->importProducts($_POST['db_switch']);
-
- if ($rslt == false) {
- echo '[[0|'.$upgrader->displayMessage().']]';
- return false;
- }
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importProducts($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
- echo '[[1]]';
- return true;
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_products_description':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importProductsDescription($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_products_notifications':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importProductsNotifications($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_products_to_categories':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importProductsToCategories($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_manufacturers':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importManufacturers($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_manufacturers_info':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importManufacturersInfo($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_reviews':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importReviews($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_specials':
+ {
+
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importSpecials($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
}
exit;
break;
case 'import_attributes':
{
- $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
- $upgrader->setConnectDetails($_POST);
- $rslt = $upgrader->importAttributes($_POST['db_switch']);
-
- if ($rslt == false) {
- echo '[[0|'.$upgrader->displayMessage().']]';
- return false;
- }
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importAttributes($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
- echo '[[1]]';
- return true;
+ echo '[[1]]';
+ return true;
}
exit;
break;
+ case 'import_featured':
+ {
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importFeatured($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
case 'import_orders':
{
- require_once("includes/classes/upgrader.php");
- $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
- $upgrader->setConnectDetails($_POST);
- $rslt = $upgrader->importOrders($_POST['db_switch']);
-
- if ($rslt == false) {
- echo '[[0|'.$upgrader->displayMessage().']]';
- return false;
- }
-
- echo '[[1]]';
- return true;
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrders($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_orders_products':
+ {
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrdersProducts($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_orders_products_download':
+ {
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrdersProductsDownload($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_orders_status':
+ {
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrdersStatus($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_orders_status_history':
+ {
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrdersStatusHistory($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
+ }
+ exit;
+ break;
+
+ case 'import_orders_total':
+ {
+ require_once("includes/classes/upgrader.php");
+ $upgrader = UpgraderFactory::create($_POST['upgrade_method']);
+ $upgrader->setConnectDetails($_POST);
+ $rslt = $upgrader->importOrdersTotal($_POST['db_switch']);
+
+ if ($rslt == false) {
+ echo '[[0|'.$upgrader->displayMessage().']]';
+ return false;
+ }
+
+ echo '[[1]]';
+ return true;
}
exit;
break;
diff --git a/catalog/install/templates/css/styles/form.css b/catalog/install/templates/css/styles/form.css
index 7611e011e..764cc5b10 100644
--- a/catalog/install/templates/css/styles/form.css
+++ b/catalog/install/templates/css/styles/form.css
@@ -1561,9 +1561,9 @@ input:-moz-placeholder {
.field-block .label,
.field-drop .label {
float: left;
- text-align: right;
- margin: 0 0 0 -190px;
- width: 170px;
+ margin: 0 0 0 -225px;
+ text-align: right;
+ width: 240px;
}
/* Field drop */
diff --git a/catalog/install/templates/pages/upgrade_1.php b/catalog/install/templates/pages/upgrade_1.php
index 8246fef0d..b1fcb4266 100644
--- a/catalog/install/templates/pages/upgrade_1.php
+++ b/catalog/install/templates/pages/upgrade_1.php
@@ -190,7 +190,7 @@
-
+