[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Помогите, xml вывод старой цены
Leperrr
Новая цена (price_one) выводится, а старая цена(price_old) вместе с новой нет, по о дельности если заменить на (price_old) то будет выводится старая, а новая нет...

Помогите пожалуйста.


<?php

class integration_yandex extends Model
{

protected $template_path = null;

public function __construct()
{
parent::Model();

$this->load->model('model_products');
$this->load->model('main_model');
$this->load->model('model_shop');
$this->load->model('calendar_model');
$this->load->model('page_type');
$this->load->model('model_products_select');
$this->load->model('model_products_integration');
}

public function index()
{
$id = $this->input->get('id');

$pro_page_name = $this->model_page->getDBPageName(SHOP_PAGE_TYPE);

$percent = $this->model_products_integration->getIntegrationPercent($id)/100;

$query_cat = "select id,pro_cat_id,pro_cat_title from products_categories where visible='Y' ";
$res_cat = $this->db->query($query_cat);
$file_export = '';
$file_export .= '<?xml version="1.0" encoding="windows-1251"?><!DOCTYPE yml_catalog SYSTEM "shops.dtd">';
$file_export .= '<yml_catalog date="' . date("Y-m-d h:i") . '"><shop>';
$file_export .= '<name>' . iconv("UTF-8", "cp1251", $this->config->item("company_name")) . '</name>
<company>' . iconv("UTF-8", "cp1251", $this->config->item("company_name")) . '</company>';
$file_export .= '<url>http://' . $this->config->item('site_location') . '</url>';
$file_export .= '<currencies><currency id="RUR" rate="NBU"/>
<currency id="USD" rate="NBU"/>
<currency id="EUR" rate="NBU"/>
<currency id="UAH" rate="1"/></currencies>';
$file_export .= '<categories>';
$file_export_data = '';
$file_export_cat = '';
foreach ($res_cat->result_array() as $row) {
$pro_category = $row['id'];
$p_cat_id = $row['pro_cat_id'];
$pro_cat_title = $row['pro_cat_title'];
if ($this->model_products_integration->getIntegrationCat($pro_category, $id)) {
$query = "select id,pro_cat_id,pro_title,pro_sml_image,product_content,price_old,price_one,availability,pro_url, in d_id,product_content_sml from products where pro_cat_id='" . $pro_category . "' and availability='1' AND `upload_price`='Y' ";
$res = $this->db->query($query);


$pro_cat_title = iconv("UTF-8", "cp1251", $pro_cat_title);
if ($p_cat_id <> 0) {
$p_cat_id = ' parentId="' . $p_cat_id . '" ';
} else {
$p_cat_id = '';
}

$file_export_cat .= '<category id="' . $pro_category . '" ' . $p_cat_id . '>' . $pro_cat_title . '</category>';


foreach ($res->result_array() as $row) {
$pid = $row['id'];
$pro_cat_id = $row['pro_cat_id'];
$pro_title = $row['pro_title'];
$pro_sml_image = $row['pro_sml_image'];
$product_content = $row['product_content'];
$price_old =number_format(($row['price_old'] - $row['price_old']*$percent), 2, '.', '');

$price_one =number_format(($row['price_one'] - $row['price_one']*$percent), 2, '.', '');
$mit_pro = $row['availability'];
$pro_url = $row['pro_url'];
$internal_id = $row['ind_id'];
$product_content_sml = $row['product_content_sml'];

if (intval($price_one) <> 0 and isset($pro_sml_image)) {
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p1')) {

$file_csv_arr['p1'] = '' . $pro_cat_title . '';
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p2')) {
$product_title = stripslashes($pro_title);
$product_title = iconv("UTF-8", "cp1251//IGNORE", $product_title);
$file_csv_arr['p2'] = '' . $product_title . '';
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p3')) {
if (($pro_sml_image == "0") || ($pro_sml_image == "NULL") || trim($pro_sml_image) == "") {
$product_image = "";
} else {
$product_image = "http://" . $this->config->item('site_location') . "/data/products/big/" . $pro_sml_image;
}
$file_csv_arr['p3'] = $product_image;
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p4')) {
$words_count = 900;

$product_descr = strip_tags($product_content, '<a><b>');
$product_descr = strtr($product_descr, "&nbsp;", " ");
$product_descr = htmlspecialchars($product_descr);
$product_descr = strtr($product_descr, " ", " ");
$product_descr = word_limiter($product_descr, $words_count);
$product_descr = iconv("UTF-8", "cp1251", $product_descr);
$file_csv_arr['p4'] = '' . $product_descr . '';
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p5')) {
$file_csv_arr['p5'] = $price_old;
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p6')) {
$file_csv_arr['p6'] = $price_one;
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p7')) {
$file_csv_arr['p7'] = $internal_id;
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p8')) {
$file_csv_arr['p8'] = $mit_pro;
}
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p9')) {
$product_content_sml = iconv("UTF-8", "cp1251", $product_content_sml);
$file_csv_arr['p9'] = '' . $product_content_sml . '';
}

if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, 'p11')) {
if (!$pro_url) {
$pro_url = $pid;
}
$product_link = "http://" . $this->config->item('site_location') . "/" . $pro_page_name . "/descriptions/" . $pro_url . "/";
$file_csv_arr['p11'] = $product_link;
}
$table_name = table_name_option($pro_cat_id);
$query_f = "select id,title,value,parent_table from products_option where pro_cat_id=" . $pro_cat_id . " order by order_no";
$res_f = $this->db->query($query_f);
foreach ($res_f->result_array() as $row_f) {
$f_id = $row_f['id'];
$f_parent_table = $row_f['parent_table'];
$kf_name = col_name_option($f_id);
$f_mit = 'v' . $f_id;
if ($this->model_products_integration->getIntegrationCatSel($pro_category, $id, $f_mit)) {
if ($kf_name <> 'p000') {
$query_d = 'select ' . $kf_name . ' as kf from ' . $table_name . ' where product_id=' . $pid;
$result_d = $this->db->query($query_d);

$row_d = $result_d->result_array();
if (isset($row_d['kf']) && $row_d['kf'] != '') {
if ($f_parent_table == 'dictionaries') {
$kf_value = $this->model_products_select->getProductPropertyValue($row_d['kf']);
} else {
$kf_value = $row_d['kf'];
}
} else {
$kf_value = '';
}
} else {
$kf_value = '';
}
$kf_value = iconv("UTF-8", "cp1251", $kf_value);
$file_csv_arr[$f_mit] = $kf_value;
}
}

$query_d = "select field from products_intagration_set where integration_id=" . $id . " and cat_id=" . $pro_cat_id . " and is_type='Y' order by order_no";

$r_d = $this->db->query($query_d);
if ($mit_pro <> 1) {
$av = ' available="false" ';
} else {
$av = ' available="true" ';
}
$file_export_data .= "<offer id=\"" . $pid . "\" " . $av . ">
";

foreach ($r_d->result_array() as $r_f) {
$f_field = $r_f['field'];

//if($i_separator<>0){$file_export .=$separator;} else{$i_separator=1;}
if ($f_field == 'p2') {
$file_export_data .= "<name>" . htmlspecialchars($file_csv_arr[$f_field]) . "</name>
";
} else if ($f_field == 'p11') {
$file_export_data .= "<url>" . $file_csv_arr[$f_field] . "</url>
";
} else if ($f_field == 'p6') {
$file_export_data .= "<price>" . $file_csv_arr[$f_field] . "</price>
<currencyId>UAH</currencyId>
";
} else if ($f_field == 'p5') {
$file_export_data .= "<oldprice>" . $file_csv_arr . "</oldprice>
<currencyId>UAH</currencyId>
";
} else if ($f_field == 'p1') {
$file_export_data .= "<categoryId>" . $pro_cat_id . "</categoryId>
";
} else if ($f_field == 'p3') {
$file_export_data .= "<picture>" . $file_csv_arr[$f_field] . "</picture>
";
} else if ($f_field == 'p4') {
$file_export_data .= "<description>" . htmlspecialchars($file_csv_arr[$f_field]) . "</description>
";
} else {
/* $file_export_data .= "<vendor>".htmlspecialchars($file_csv_arr[$f_field])."</vendor>
"; */
}


}
$file_export_data .= "</offer>";
}
}

}


}

$file_export .= $file_export_cat . "</categories>
<offers>" . $file_export_data . "</offers></shop></yml_catalog>";


$file_name = $this->model_products_integration->getIntegrationFile($id);
//$file_export = iconv("UTF-8","cp1251",$file_export);
$file_n = SITE_ROOT_BASE . '/files/' . $file_name;
$handle = fopen($file_n, "w");
fwrite($handle, $file_export);
fclose($handle);
chmod($file_n, 0666);

$query = 'UPDATE products_intagration SET create_date=now() WHERE id=' . $id;
$this->db->query($query);

}
}

?>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.