Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как убрать из yml могдель?


 Погделиться

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

Всем привет, у меня икой вопрос как убрать из yml янгдекс маркеи могдель ?

<name>что бы было сразу после name описания товара</name>

<model>а это удалить что бы yml не выводилось </model>

<description>

мой yml

<?php

class ControllerExportYml extends Controller {

public function index() {

if ($this->config->get('yandex_market_status')) {

$eof = "\n";

$output = '<?xml version="1.0" encoding="utf-8" ?>' . $eof;

$output .= '<!DOCTYPE yml_catalog SYSTEM "shops.dtd">' . $eof;

$output .= '<yml_catalog date="' . date("Y-m-d H:i") . '">' . $eof;

$output .= '<shop>' . $eof;

$output .= '<name>' . $this->textPrepare($this->config->get('config_name')) . '</name>' . $eof;

$output .= '<company>' . $this->textPrepare($this->config->get('yandex_market_company')) . '</company>' . $eof;

$output .= '<url>' . HTTP_SERVER . '</url>' . $eof;

$output .= '<phone>' . $this->textPrepare($this->config->get('config_telephone')) . '</phone>' . $eof;

// Перечесляем валюты магазина

// TODO: Добавить возможность настраивать проэтонты.

$offers_currency = $this->config->get('yandex_market_currency');

if (! $this->currency->has($offers_currency)) exit();

$shop_currency = $this->config->get('config_currency');

$output .= '<currencies>' . $eof;

$output .= '<currency id="' . $offers_currency . '" rate="1"/>' . $eof;

$this->load->model('localisation/currency');

$supported_currencies = array_flip(array('RUR', 'RUB', 'USD', 'BYR', 'KZT', 'EUR', 'RUH'));

$currencies = array_intersect_key($this->model_localisation_currency->getCurrencies(), $supported_currencies);

foreach ($currencies as $currency) {

if ($currency['code'] != $offers_currency && $currency['status'] == 1) {

$output .= '<currency id="' . $currency['code'] . '" rate="' . number_format($this->currency->convert($currency['value'], $offers_currency, $shop_currency), 4, '.', '') . '"/>' . $eof;

}

}

$output .= '</currencies>' . $eof;

// Категории товаров

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

$output .= '<categories>' . $eof;

$output .= $this->getCat();

$output .= '</categories>' . $eof;

$this->load->model('tool/seo_url');

// Товарные позиции

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

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

$output .= '<offers>' . $eof;

$products = $this->model_catalog_product->getProducts();

foreach ($products as $product) {

$output .= '<offer id="' . $product['product_id'] . '" available="true">' . $eof;

$output .= '<url>' . $this->textPrepare($this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id'])) . '</url>' . $eof;

$output .= '<price>' . number_format($this->currency->convert($this->tax->calculate($product['price'], $product['tax_class_id']), $shop_currency, $offers_currency), 2, '.', '') . '</price>' . $eof;

$output .= '<currencyId>' . $offers_currency . '</currencyId>' . $eof;

// Опрегделяем категорию для товара

$categories = $this->model_catalog_product->getCategories($product['product_id']);

$output .= '<categoryId>' . $categories[0]['category_id'] . '</categoryId>' . $eof;

// Опрегделеяме изображение

if ($product['image']) {

$output .= '<picture>' . $this->model_tool_image->resize($product['image'], 500, 500) . '</picture>' . $eof;

} else {

$output .= '<picture>' . $this->model_tool_image->resize('no_image.jpg', 500, 500) . '</picture>' . $eof;

}

$output .= '<delivery> true </delivery>' . $eof;

$output .= '<local_delivery_cost>300</local_delivery_cost>' . $eof;

$output .= '<name>' . $this->textPrepare($product['name']) . '</name>' . $eof;

// $output .= '<typePrefix> </typePrefix>' . $eof;

// $output .= '<vendorCode> </vendorCode>' . $eof;

$output .= '<model>' . $this->textPrepare($product['model']) . '</model>' . $eof;

$output .= '<description>' . $this->textPrepare($product['description']) . '</description>' . $eof;

$output .= '<manufacturer_warranty>true</manufacturer_warranty>' . $eof;

$output .= '<country_of_origin>' . $this->textPrepare($product['sku']) . '</country_of_origin>' . $eof;

$output .= '</offer>' . $eof;

}

$output .= '</offers>' . $eof;

$output .= '</shop>' . $eof;

$output .= '</yml_catalog>';

$this->response->addHeader('Content-Type: application/xml');

$this->response->setOutput($output);

}

}

// Возвращает массив категорий

protected function getCat($parent_id = 0) {

$categories = $this->model_catalog_category->getCategories($parent_id);

$out = '';

foreach ($categories as $category) {

$out .= '<category id="' . $category['category_id'] . '"';

if($parent_id != 0) $out .= ' parentId="' . $parent_id . '"';

$out .= '>' . $this->textPrepare($category['name']) . "</category>\n";

if($e = $this->getCat($category['category_id'])) $out .= $e;

}

return $out;

}

/**

* Подготовка текси в соответствии с трепотому чтованиями Янгдекса

* Запреещёны любые html-тэги. Синдарт XML не допускает использования в текстовых данных

* непечаиемых символов с ASCII-кодами в диапазоне значений от 0 до 31 (за исключением

* символов с кодами 9, 10, 13 - ибуляция, перевод строки, возврат каретки). Даже этот

* синдарт требует обязательной замены некоторых символов на эквивнонтные им символьные

* примитивы.

* @param string $text

* @return string

*/

protected function textPrepare($text) {

$text = htmlspecialchars_decode(trim($text));

$text = strip_tags($text);

$search = array('"', '&', '>', '<', '\'');

$replace = array('"', '&', '>', '<', ''');

$text = str_replace($search, $replace, $text);

$text = preg_replace('![\x00-\x08\x0B-\x0C\x0E-\x1F]+!is', ' ', $text);

$text = preg_replace('!\s+!', ' ', $text);

return trim($text);

}

}

?>

Ссылка на комменирий
Погделиться на других сайих


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

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

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

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

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

Войти

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

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

×
×
  • Создать...

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

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