Перейти к публикации
Поиск в
  • Дополнительно...
Искать результаты, содержащие...
Искать результаты в...

XML Экспорт


 Поделиться

Рекомендованные сообщения

Подскажите как переделать данный скрипт экспорта xml для вывода данных на двух языках ,данный скрипт может выводить на нескольких языках но по отдельности хотелось бы  объединить два в одном скрипте.

<?php
class ControllerFeedShopXML extends Controller {
private $currencies = array();

public function index() {
if ($this->config->get('shopxml_status')) {

$xmlstr = '<?xml version="1.0" encoding="utf-8" ?>

<root></root>';

$xml = new SimpleXMLElement($xmlstr);

if(isset($_GET["lang_export"])){
$languages = array();
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "language` WHERE status = '1'");
foreach($query->rows as $result){
$languages[$result['code']] = $result;
}
if(isset($languages[$_GET["lang_export"]]["language_id"])){
$this->config->set("config_language", $_GET["lang_export"]);
$this->config->set("config_language_id", $languages[$_GET["lang_export"]]["language_id"]);
}
}

$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->load->model('tool/image');

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency");

foreach ($query->rows as $result) {
if($result['status'] == 1){
$this->currencies[$result['code']] = array(
'currency_id' => $result['currency_id'],
'title' => $result['title'],
'symbol_left' => $result['symbol_left'],
'symbol_right' => $result['symbol_right'],
'decimal_place' => $result['decimal_place'],
'value' => $result['value']
);
}
}

if(isset($this->request->get['cur_export']) && (array_key_exists($this->request->get['cur_export'], $this->currencies))){
$this->currency->set($this->request->get['cur_export']);
} else{
$this->currency->set($this->config->get('config_currency'));
}


$products = $this->model_catalog_product->getProducts();
foreach($products as $product){
$item = $xml->addChild('item');
$item->name = $product['name'];
if(isset($product["description"]) && isset($_GET["desc_export"])){
$item->description = html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8') ;
}

if($product['image']){
$item->image = $this->model_tool_image->resize($product['image'], 500, 500);
} else{
$item->image = $this->model_tool_image->resize('no_image.jpg', 500, 500);
}
$categories = $this->model_catalog_product->getCategories($product['product_id']);
$string = '';
$lastCat = '';
$caturl = '';
foreach($categories as $category){
$path = $this->getPath($category['category_id']);
$caturl = HTTP_SERVER . $this->config->get("config_language").'/'.'index.php?route=product/category&path=' . $path;
if($path){
foreach(explode('_', $path) as $path_id){
$category_info = $this->model_catalog_category->getCategory($path_id);
$lastCat = $category_info['name'];
if($category_info){
if(!$string){
$string = $category_info['name'];
} else{
$string .= ' >> ' . $category_info['name'];
}
}
}
}
break;
}


$currency_code = $this->currency->getCode();
$currency_value = $this->currency->getValue();

$item->link = HTTP_SERVER . $this->config->get("config_language").'/'.'?route=product/product&product_id=' . $product['product_id'].'&currency='.$currency_code;
$caturl .= '&currency='.$currency_code;



if((float)$product['special']){
$item->price = $this->currency->format($this->tax->calculate($product['special'],
$product['tax_class_id']),
$currency_code,
$currency_value,
false);
} else{
$item->price = $this->currency->format($this->tax->calculate($product['price'],
$product['tax_class_id']),
$currency_code,
$currency_value,
false);
}
$item->category = $lastCat;
$item->category_full = $string;
$item->category_link = $caturl;
$item->manufacturer = $product['manufacturer'];
$item->model = $product['model'];
$item->in_stock = $product['quantity'];
$item->upc = $product['quantity'];
$item->weight = $product['weight'];
}
$this->response->addHeader('Content-Type: application/xml');
$this->response->setOutput($xml->asXML());





}







}

protected function getPath($parent_id, $current_path = '') {
$category_info = $this->model_catalog_category->getCategory($parent_id);
if ($category_info) {
if (!$current_path) {
$new_path = $category_info['category_id'];
} else {
$new_path = $category_info['category_id'] . '_' . $current_path;
}

$path = $this->getPath($category_info['parent_id'], $new_path);
if ($path) {
return $path;
} else {
return $new_path;
}
}
}
}
?>
Ссылка на комментарий
Поделиться на других сайтах


  • 1 месяц спустя...

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

  • Сейчас на странице   0 пользователей

    • Нет пользователей, просматривающих эту страницу.
×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.