<?php
chdir('/hosting/mebelfan.com/');
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$items = array();
$items[] = array('Диван и кресло Мальта', 'mjagkaja_mebel_kyrier.com.ua_malta_maltadiv.jpg', 18, 28, 0, 0, 0);
$items[] = array('Аккорд угловой диван', 'mjagkaja_mebel_mebus_acord_ug_26_1.jpg', 18, 28, 0, 0, 0);
$items[] = array('Диван и кресло Саванна', 'mjagkaja_mebel_kyrier.com.ua_savanna_savdiv.jpg', 18, 28, 0, 0, 0);
foreach($items as $item) {
$node = new StdClass();
$node->type = 'product';
$node->uid = 16;
$node->title = $item[0];
$node->promote = 1;
$node->field_width[0]['value'] = $item[4] == 0 ? '' : $item[4];
$node->field_depth[0]['value'] = $item[5] == 0 ? '' : $item[5];
$node->field_height[0]['value'] = $item[6] == 0 ? '' : $item[6];
$image = file_directory_path() . '/panstar/' . $item[1];
$field = content_fields('field_photo', 'product');
$validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
$files_path = filefield_widget_file_path($field);
$file = field_file_save_file($image, $validators, $files_path, FILE_EXISTS_REPLACE);
$node->field_photo = array( 0 => $file);
$node->taxonomy[1] = $item[2];
$node->taxonomy[2] = 26;
$node->taxonomy[3] = $item[3];
$node->taxonomy[4] = 163;
$node->taxonomy[5] = 164;
node_save($node);
echo '<a href="http://mebelfan.com/node/' . $node->nid . '/edit">http://mebelfan.com/node/' . $node->nid . '/edit</a><br />';
}