Custom import script guide

Import is a big problem, because all systems are different, don’t support same fields/parameters/languages, database structure is different, export formats also. So there is no universal solution for this. I will try to help you with building import bridge script here. (SQL/PHP/XML/CodeIgniter Skills are required).

Lets say that you already have your data in some PHP array or object (this fully depends on your custom data).

Now you want create bridge script that will import this data into real estate script database.

Best way is to use existing model methods and not import directly to database tables because of future script compatibility.

In codeigniter you should create new controller, some instructions here:
http://www.codeigniter.com/user_guide/general/controllers.html

In that new controller you should use estate_m model like I use it in file application\controllers\admin\estate.php if you want to look in, methods:

$this->estate_m->save

and
$this->estate_m->save_dynamic

Read about models here (how to load and use):
http://www.codeigniter.com/user_guide/general/models.html

For each estate you should call this 2 methods.

DB model if you want to see tables directly related to properties in version 1.5.2.:

db-model

Example code

You can also see example code that generate fake/dummy data for benchmark purposes:
application\controllers\admin\benchmarktool.php, method:
public function fake_listings($listing_num)
You can enable benchmark tool to become visible in administration adding this to application\config\cms_config.php:
$config['enable_benchmark_tools'] = TRUE;

Import images

You should create file repository:
$estate = estate object

// Fetch file repository
 $repository_id = $estate->repository_id;
 if(empty($repository_id))
 {
 // Create repository
 $repository_id = $this->repository_m->save(array('name'=>'estate_m'));

// Update estate object with new repository_id
$this->estate_m->save(array('repository_id'=>$repository_id), $estate->id);
}

Then you shoud insert files into this repository:

$next_order = order number, 1,2,3,4…

 // Add file to repository
 $file_id = $this->file_m->save(array(
 'repository_id' => $repository_id,
 'order' => $next_order,
 'filename' => 'your_file.jpg',
 'filetype' => 'image/jpeg'
 ));

Don’t forget to create 2 files:
files\thumbnail\
and
files\