Init(); require_once FULL_PATH.'/admin/install/install_lib.php'; // create module category $application->setUnitOption('c','AutoLoad',false); $cat =& $application->recallObject('c'); $cat_fields = Array('Name' => 'Products', 'AutomaticFilename' => 1, 'Filename' => 'Products', 'Description' => 'Product Catalog', 'Status' => 1, 'ParentId' => 0, 'CategoryTemplate' => 'in-commerce/store/category', 'ItemTemplate' => 'in-commerce/product/details', 'CachedCategoryTemplate' => 'in-commerce/store/category', 'CachedItemTemplate' => 'in-commerce/product/details'); $cat->SetDBFieldsFromHash($cat_fields); $cat->Create(); $cat_id = $cat->GetId(); $filename = FULL_PATH.'/'.$MODULE_NAME.'/admin/install/inportal_schema.sql'; if( file_exists($filename) ) RunSchemaFile($application->DB, $filename, 'dbconnection'); $filename = FULL_PATH.'/'.$MODULE_NAME.'/admin/install/inportal_data.sql'; if( file_exists($filename) ) { $sql = file($filename); for($x = 0; $x < count($sql); $x++) { $sql[$x] = str_replace('{ProductCatId}', $cat_id, $sql[$x]); } RunSQLText($application->DB, $sql,'dbconnection'); if($ini_file == '') { $ini_file = FULL_PATH.'/config.php'; $ini_vars = inst_parse_portal_ini($ini_file, true); } $sql = 'SELECT Version FROM '.TABLE_PREFIX.'Modules WHERE Name = '.$application->DB->qstr('In-Commerce'); $mod_version = $application->DB->GetOne($sql); set_ini_value('Module Versions', 'In-Commerce', $mod_version); save_values(); $application->refreshModuleInfo(); // this module configs are now processed } // link in-commerce SearchConfig records with corresponding custom fields $db =& $application->GetADODBConnection(); $sql = 'SELECT FieldName, CustomFieldId FROM '.TABLE_PREFIX.'CustomField WHERE Type = 11'; // config is not read here yet :( $application->getUnitOption('p', 'ItemType'); $custom_fields = $db->GetCol($sql, 'CustomFieldId'); foreach ($custom_fields as $cf_id => $cf_name) { $sql = 'UPDATE '.TABLE_PREFIX.'SearchConfig SET CustomFieldId = '.$cf_id.' WHERE (TableName = "CustomField") AND (ModuleName = "In-Commerce") AND (FieldName = '.$db->qstr($cf_name).')'; $db->Query($sql); } // because of configs was read only from installed before modules (in-portal), then reread configs $unit_config_reader =& $application->recallObject('kUnitConfigReader'); $unit_config_reader->scanModules(MODULES_PATH.'/'.$MODULE_NAME); // create correct columns in ProductsCustomData table $ml_helper =& $application->recallObject('kMultiLanguageHelper'); $ml_helper->createFields('p-cdata'); $sql = 'DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"'; $application->DB->Query($sql); $sql = 'UPDATE '.TABLE_PREFIX.'Modules SET RootCat = '.$cat_id.' WHERE Name = '.$application->DB->qstr('In-Commerce'); $application->DB->Query($sql); $inp_cat =& $objCatList->GetCategory($cat_id); $inp_cat->UpdateCachedPath(); $inp_cat->UpdateACL(); finalizeModuleInstall($MODULE_NAME); ?>