Импорт товаров с картинками (лыжи не едут?)
Проблема в следующем импортируем в CSV все круто, кроме одного нет поля с картинкой большой и маленькой хотя у товара они есть.Облазил все что мог так и не нашол решения.
Причем картинка то не доп свойство.Как решить задачку?
Причем картинка то не доп свойство.Как решить задачку?
TDE,
Есть поля и называются они "Файл изображения для товара" и "Файл малого изображения для товара", размещены на голубом фоне после "Текст для товара".
Есть поля и называются они "Файл изображения для товара" и "Файл малого изображения для товара", размещены на голубом фоне после "Текст для товара".
Так вот у меня нет таких полей в csv (версия последняя).Надо так экспортнул "с картинками" и залил с ними же.
TDE,
Скачайте с сайта Халяву 5.8.4, замените из нее полностью /admin/shop/
Скачайте с сайта Халяву 5.8.4, замените из нее полностью /admin/shop/
Видимо не понимаем друг друга.(я не вижу полей экспорта картинок) а вы.
Я в первом посте слово импорт с экспортом перепутал.(гы) Экспорт товаров так надо.С импортом все гуд поля есть точно знаю.
Я в первом посте слово импорт с экспортом перепутал.(гы) Экспорт товаров так надо.С импортом все гуд поля есть точно знаю.
<?php
/**
* Система управления сайтом HostCMS v. 5.xx
* Copyright © 2005-2008 ООО "Хостмэйк" (Hostmake LLC),
*
* Обработчик экспорта данных о товарах в CSV.
*
* Файл: /admin/shop/action/export_data_csv.php
*
* @author Hostmake LLC
* @version 5.2
*/
$shop = & singleton('shop');
$kernel = & singleton('kernel');
$DataBase = & singleton('DataBase');
// Получаем родительскую группу, с котрой нужно начать экспорт
$shop_groups_parent_id = to_int($_REQUEST['shop_groups_parent_id']);
$shop_shops_id = to_int($_REQUEST['shop_shops_id']);
// Получаем список групп товаров, которые войдут в конечный XML-документ
$array_of_groups = $shop->GetGroupsTree($shop_groups_parent_id, $shop_shops_id);
// В цикле получаем список товаров, которые войдут в конечный XML-документ
$array_of_items = array();
// Запрос на получение данных о товарах для всех категориях
$query = "SELECT * FROM `shop_items_catalog_table` WHERE ";
$where_case = "(`shop_groups_id`='$shop_groups_parent_id'";
$array_of_groups_id = array();
foreach ($array_of_groups AS $parent_group_id => $array_of_child_groups)
{
if (!in_array($parent_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $parent_group_id;
$where_case .= " OR `shop_groups_id`='" . $parent_group_id . "'";
}
foreach ($array_of_child_groups AS $child_group_id => $child_data)
{
if (!in_array($child_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $child_group_id;
$where_case .= " OR `shop_groups_id`='" . $child_group_id . "'";
}
if (!in_array($child_data['shop_groups_id'], $array_of_groups_id))
{
$array_of_groups_id[] = $child_data['shop_groups_id'];
$where_case .= " OR `shop_groups_id`='" . $child_data['shop_groups_id'] . "'";
}
}
}
$where_case .= ') AND shop_shops_id=' . $shop_shops_id . ' AND `shop_items_catalog_modification_id`=0';
$query .= $where_case;
$items_res = $DataBase->query($query);
// Начинаем отправлять заголовки
header("Pragma: public");
header("Content-Description: File Transfer");
// Указываем уже определенный Content-Type
header("Content-Type: application/force-download");
// Force the download
header("Content-Disposition: attachment; filename = " . 'CSV_' .date("Y_m_d_H_i_s").'.csv'. ";");
header("Content-Transfer-Encoding: binary");
$export_price_separator = to_int($_REQUEST['export_price_separator']);
switch($export_price_separator)
{
case 0:
$export_price_separator = ',';
break;
case 1:
default:
$export_price_separator = ';';
break;
case 2:
$separator = to_str($_REQUEST['import_price_separator_text']);
if(trim($separator) != '')
{
$export_price_separator = $separator;
}
else
{
$export_price_separator = ';';
}
break;
}
// Выводим заголовок CSV
echo '"Название раздела"'.$export_price_separator.'"CML GROUP ID идентификатор группы товаров"'.$export_price_separator.'"CML GROUP ID идентификатор родительской группы товаров"'.$export_price_separator.'"Заголовок раздела(title)"'.$export_price_separator.'"Описание раздела(description)"'.$export_price_separator.'"Ключевые слова раздела(keywords)"'.$export_price_separator.'"Описание раздела"'.$export_price_separator.'"Путь для раздела"'.$export_price_separator.'"Название товара"'.$export_price_separator.'"Описание товара"'.$export_price_separator.'"Артикул товара"'.$export_price_separator.'"Текст для товара"'.$export_price_separator.'"Вес товара"'.$export_price_separator.'"Тип товара"'.$export_price_separator.'"Количество на складе"'.$export_price_separator.'"Цена товара"'.$export_price_separator.'"Активность товара"'.$export_price_separator.'"Порядок сортировки товара"'.$export_price_separator.'"Путь к товару"'.$export_price_separator.'"Идентификатор налога для товара"'.$export_price_separator.'"Идентификатор валюты"'.$export_price_separator.'"Название продавца"'.$export_price_separator.'"Название производителя"'.$export_price_separator.'"Название единицы измерения"'.$export_price_separator.'"Заголовок страницы с товаром"'.$export_price_separator.'"Значение мета-тега description для страницы с товаром"'.$export_price_separator.'"Значение мета-тега keywords для страницы с товаром"'.$export_price_separator.'"Флаг индексации"'.$export_price_separator.'"Флаг ""Экспортировать в Яндекс.Маркет"""'.$export_price_separator.'"Флаг ""Экспортировать в Рамблер-Покупки"""'.$export_price_separator.'"Яндекс.Маркет основная расценка"'.$export_price_separator.'"Яндекс.Маркет расценка для карточек моделей"'.$export_price_separator.'"Дата"'.$export_price_separator.'"Дата публикации"'.$export_price_separator.'"Дата завершения публикации"'."\r\n";
// Начинаем экспорт групп
foreach ($array_of_groups AS $parent_key => $data)
{
foreach ($data AS $group_id)
{
$metadata = $shop->GetGroup($group_id);
if ($metadata)
{
// Генерируем идентификатор группы CommerceML
$id_group = GenCmlId($metadata['shop_groups_id']);
$id_parent_group = GenCmlId($metadata['shop_groups_parent_id']);
$shop_groups_name = str_replace('"', '""',$metadata['shop_groups_name']);
$shop_groups_description = str_replace('"', '""',$metadata['shop_groups_description']);
$shop_groups_path = $metadata['shop_groups_path'];
$shop_groups_seo_title = str_replace('"', '""',$metadata['shop_groups_seo_title']);
$shop_groups_seo_description = str_replace('"', '""',$metadata['shop_groups_seo_description']);
$shop_groups_seo_keywords = str_replace('"', '""',$metadata['shop_groups_seo_keywords']);
// Получаем название родительской группы
$group_row = $shop->GetGroup($id_parent_group);
echo '"' . $shop_groups_name . '"'.$export_price_separator.'"' . $id_group . '"'.$export_price_separator.'"' . $id_parent_group . '"'.$export_price_separator.'"'.$shop_groups_seo_title.'"'.$export_price_separator.'"'.$shop_groups_seo_description.'"'.$export_price_separator.'"'.$shop_groups_seo_keywords.'"'.$export_price_separator.'"' . str_replace('"', '""', $shop_groups_description) . '"'.$export_price_separator.'"' . $shop_groups_path .'"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'."\r\n";
}
}
}
// Начинаем экспорт товаров
while ($item_data = mysql_fetch_assoc($items_res))
{
$item_id = $item_data['shop_items_cml_id'];
if ($item_id == '')
{
$item_id = GenCmlId($item_data['shop_items_catalog_item_id']);
}
$id_parent_item = GenCmlId($item_data['shop_groups_id']);
// Получаем информацию о еденице измерения
$item_mesure_row = $shop->GetMesure($item_data['shop_mesures_id']);
// Получаем имя продавца
$seller_row = $shop->GetSeller($item_data['shop_sallers_id']);
// Получаем название производителя
$producer_row = $shop->GetProducer($item_data['shop_producers_list_id']);
// Получаем название единицы измерения
$mesures_row = $shop->GetMesure($item_data['shop_mesures_id']);
echo '""'.$export_price_separator.'"' .
$id_parent_item . '"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'"' .
$item_data['shop_items_catalog_name'] .'"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_description']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_marking'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_text']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_weight'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_type'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rest'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_price'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_is_active'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_order'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_path'] . '"'.$export_price_separator.'"' .
$item_data['shop_tax_id'] . '"'.$export_price_separator.'"' .
$item_data['shop_currency_id'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $seller_row['shop_sallers_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$producer_row['shop_producers_list_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$mesures_row['shop_mesures_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_title']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_description']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_keywords']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_indexation'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rambler_pokupki_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_bid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_cid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_date_time'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putoff_date'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putend_date'] . '"'."\r\n";
}
function GenCmlId($shop_groups_id)
{
$temp = 'ID';
$shop_groups_id = to_str($shop_groups_id);
$len = 8 - strlen($shop_groups_id);
for ($i = 0; $i < $len; $i++)
{
$temp .= '0';
}
return $temp .= $shop_groups_id;
}
exit();
?>
/**
* Система управления сайтом HostCMS v. 5.xx
* Copyright © 2005-2008 ООО "Хостмэйк" (Hostmake LLC),
*
* Обработчик экспорта данных о товарах в CSV.
*
* Файл: /admin/shop/action/export_data_csv.php
*
* @author Hostmake LLC
* @version 5.2
*/
$shop = & singleton('shop');
$kernel = & singleton('kernel');
$DataBase = & singleton('DataBase');
// Получаем родительскую группу, с котрой нужно начать экспорт
$shop_groups_parent_id = to_int($_REQUEST['shop_groups_parent_id']);
$shop_shops_id = to_int($_REQUEST['shop_shops_id']);
// Получаем список групп товаров, которые войдут в конечный XML-документ
$array_of_groups = $shop->GetGroupsTree($shop_groups_parent_id, $shop_shops_id);
// В цикле получаем список товаров, которые войдут в конечный XML-документ
$array_of_items = array();
// Запрос на получение данных о товарах для всех категориях
$query = "SELECT * FROM `shop_items_catalog_table` WHERE ";
$where_case = "(`shop_groups_id`='$shop_groups_parent_id'";
$array_of_groups_id = array();
foreach ($array_of_groups AS $parent_group_id => $array_of_child_groups)
{
if (!in_array($parent_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $parent_group_id;
$where_case .= " OR `shop_groups_id`='" . $parent_group_id . "'";
}
foreach ($array_of_child_groups AS $child_group_id => $child_data)
{
if (!in_array($child_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $child_group_id;
$where_case .= " OR `shop_groups_id`='" . $child_group_id . "'";
}
if (!in_array($child_data['shop_groups_id'], $array_of_groups_id))
{
$array_of_groups_id[] = $child_data['shop_groups_id'];
$where_case .= " OR `shop_groups_id`='" . $child_data['shop_groups_id'] . "'";
}
}
}
$where_case .= ') AND shop_shops_id=' . $shop_shops_id . ' AND `shop_items_catalog_modification_id`=0';
$query .= $where_case;
$items_res = $DataBase->query($query);
// Начинаем отправлять заголовки
header("Pragma: public");
header("Content-Description: File Transfer");
// Указываем уже определенный Content-Type
header("Content-Type: application/force-download");
// Force the download
header("Content-Disposition: attachment; filename = " . 'CSV_' .date("Y_m_d_H_i_s").'.csv'. ";");
header("Content-Transfer-Encoding: binary");
$export_price_separator = to_int($_REQUEST['export_price_separator']);
switch($export_price_separator)
{
case 0:
$export_price_separator = ',';
break;
case 1:
default:
$export_price_separator = ';';
break;
case 2:
$separator = to_str($_REQUEST['import_price_separator_text']);
if(trim($separator) != '')
{
$export_price_separator = $separator;
}
else
{
$export_price_separator = ';';
}
break;
}
// Выводим заголовок CSV
echo '"Название раздела"'.$export_price_separator.'"CML GROUP ID идентификатор группы товаров"'.$export_price_separator.'"CML GROUP ID идентификатор родительской группы товаров"'.$export_price_separator.'"Заголовок раздела(title)"'.$export_price_separator.'"Описание раздела(description)"'.$export_price_separator.'"Ключевые слова раздела(keywords)"'.$export_price_separator.'"Описание раздела"'.$export_price_separator.'"Путь для раздела"'.$export_price_separator.'"Название товара"'.$export_price_separator.'"Описание товара"'.$export_price_separator.'"Артикул товара"'.$export_price_separator.'"Текст для товара"'.$export_price_separator.'"Вес товара"'.$export_price_separator.'"Тип товара"'.$export_price_separator.'"Количество на складе"'.$export_price_separator.'"Цена товара"'.$export_price_separator.'"Активность товара"'.$export_price_separator.'"Порядок сортировки товара"'.$export_price_separator.'"Путь к товару"'.$export_price_separator.'"Идентификатор налога для товара"'.$export_price_separator.'"Идентификатор валюты"'.$export_price_separator.'"Название продавца"'.$export_price_separator.'"Название производителя"'.$export_price_separator.'"Название единицы измерения"'.$export_price_separator.'"Заголовок страницы с товаром"'.$export_price_separator.'"Значение мета-тега description для страницы с товаром"'.$export_price_separator.'"Значение мета-тега keywords для страницы с товаром"'.$export_price_separator.'"Флаг индексации"'.$export_price_separator.'"Флаг ""Экспортировать в Яндекс.Маркет"""'.$export_price_separator.'"Флаг ""Экспортировать в Рамблер-Покупки"""'.$export_price_separator.'"Яндекс.Маркет основная расценка"'.$export_price_separator.'"Яндекс.Маркет расценка для карточек моделей"'.$export_price_separator.'"Дата"'.$export_price_separator.'"Дата публикации"'.$export_price_separator.'"Дата завершения публикации"'."\r\n";
// Начинаем экспорт групп
foreach ($array_of_groups AS $parent_key => $data)
{
foreach ($data AS $group_id)
{
$metadata = $shop->GetGroup($group_id);
if ($metadata)
{
// Генерируем идентификатор группы CommerceML
$id_group = GenCmlId($metadata['shop_groups_id']);
$id_parent_group = GenCmlId($metadata['shop_groups_parent_id']);
$shop_groups_name = str_replace('"', '""',$metadata['shop_groups_name']);
$shop_groups_description = str_replace('"', '""',$metadata['shop_groups_description']);
$shop_groups_path = $metadata['shop_groups_path'];
$shop_groups_seo_title = str_replace('"', '""',$metadata['shop_groups_seo_title']);
$shop_groups_seo_description = str_replace('"', '""',$metadata['shop_groups_seo_description']);
$shop_groups_seo_keywords = str_replace('"', '""',$metadata['shop_groups_seo_keywords']);
// Получаем название родительской группы
$group_row = $shop->GetGroup($id_parent_group);
echo '"' . $shop_groups_name . '"'.$export_price_separator.'"' . $id_group . '"'.$export_price_separator.'"' . $id_parent_group . '"'.$export_price_separator.'"'.$shop_groups_seo_title.'"'.$export_price_separator.'"'.$shop_groups_seo_description.'"'.$export_price_separator.'"'.$shop_groups_seo_keywords.'"'.$export_price_separator.'"' . str_replace('"', '""', $shop_groups_description) . '"'.$export_price_separator.'"' . $shop_groups_path .'"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'."\r\n";
}
}
}
// Начинаем экспорт товаров
while ($item_data = mysql_fetch_assoc($items_res))
{
$item_id = $item_data['shop_items_cml_id'];
if ($item_id == '')
{
$item_id = GenCmlId($item_data['shop_items_catalog_item_id']);
}
$id_parent_item = GenCmlId($item_data['shop_groups_id']);
// Получаем информацию о еденице измерения
$item_mesure_row = $shop->GetMesure($item_data['shop_mesures_id']);
// Получаем имя продавца
$seller_row = $shop->GetSeller($item_data['shop_sallers_id']);
// Получаем название производителя
$producer_row = $shop->GetProducer($item_data['shop_producers_list_id']);
// Получаем название единицы измерения
$mesures_row = $shop->GetMesure($item_data['shop_mesures_id']);
echo '""'.$export_price_separator.'"' .
$id_parent_item . '"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'"' .
$item_data['shop_items_catalog_name'] .'"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_description']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_marking'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_text']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_weight'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_type'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rest'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_price'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_is_active'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_order'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_path'] . '"'.$export_price_separator.'"' .
$item_data['shop_tax_id'] . '"'.$export_price_separator.'"' .
$item_data['shop_currency_id'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $seller_row['shop_sallers_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$producer_row['shop_producers_list_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$mesures_row['shop_mesures_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_title']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_description']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_keywords']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_indexation'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rambler_pokupki_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_bid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_cid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_date_time'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putoff_date'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putend_date'] . '"'."\r\n";
}
function GenCmlId($shop_groups_id)
{
$temp = 'ID';
$shop_groups_id = to_str($shop_groups_id);
$len = 8 - strlen($shop_groups_id);
for ($i = 0; $i < $len; $i++)
{
$temp .= '0';
}
return $temp .= $shop_groups_id;
}
exit();
?>
TDE,
давайте начнем с чтения заголовка этой темы и размышлений на тему отличий в понятиях экспорт и импорт.
давайте начнем с чтения заголовка этой темы и размышлений на тему отличий в понятиях экспорт и импорт.
Меня интересует ЭКСПОРТ товаров с картинками но если размышлять как вы предлагаете то если при экспорте товаров картинки отсутствуют то логично понять что и при импорте они никак не появятся.Вот и обратился к вам с этой проблемой но проблема так и не решена.Исходя из файла экспорта в котором по моему мнению отсутствуют поля картинок, думаю можно просто добавить эти поля и все будет.Теперь о главном помощь то нужна именно в том что в файл экспорта надо добавить поля картинок.Спасибо.
Теперь к делу
Теперь к делу
<?php
/**
* Система управления сайтом HostCMS v. 5.xx
* Copyright © 2005-2008 ООО "Хостмэйк" (Hostmake LLC),
*
* Обработчик экспорта данных о товарах в CSV.
*
* Файл: /admin/shop/action/export_data_csv.php
*
* @author Hostmake LLC
* @version 5.2
*/
$shop = & singleton('shop');
$kernel = & singleton('kernel');
$DataBase = & singleton('DataBase');
// Получаем родительскую группу, с котрой нужно начать экспорт
$shop_groups_parent_id = to_int($_REQUEST['shop_groups_parent_id']);
$shop_shops_id = to_int($_REQUEST['shop_shops_id']);
// Получаем список групп товаров, которые войдут в конечный XML-документ
$array_of_groups = $shop->GetGroupsTree($shop_groups_parent_id, $shop_shops_id);
// В цикле получаем список товаров, которые войдут в конечный XML-документ
$array_of_items = array();
// Запрос на получение данных о товарах для всех категориях
$query = "SELECT * FROM `shop_items_catalog_table` WHERE ";
$where_case = "(`shop_groups_id`='$shop_groups_parent_id'";
$array_of_groups_id = array();
foreach ($array_of_groups AS $parent_group_id => $array_of_child_groups)
{
if (!in_array($parent_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $parent_group_id;
$where_case .= " OR `shop_groups_id`='" . $parent_group_id . "'";
}
foreach ($array_of_child_groups AS $child_group_id => $child_data)
{
if (!in_array($child_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $child_group_id;
$where_case .= " OR `shop_groups_id`='" . $child_group_id . "'";
}
if (!in_array($child_data['shop_groups_id'], $array_of_groups_id))
{
$array_of_groups_id[] = $child_data['shop_groups_id'];
$where_case .= " OR `shop_groups_id`='" . $child_data['shop_groups_id'] . "'";
}
}
}
$where_case .= ') AND shop_shops_id=' . $shop_shops_id . ' AND `shop_items_catalog_modification_id`=0';
$query .= $where_case;
$items_res = $DataBase->query($query);
// Начинаем отправлять заголовки
header("Pragma: public");
header("Content-Description: File Transfer");
// Указываем уже определенный Content-Type
header("Content-Type: application/force-download");
// Force the download
header("Content-Disposition: attachment; filename = " . 'CSV_' .date("Y_m_d_H_i_s").'.csv'. ";");
header("Content-Transfer-Encoding: binary");
$export_price_separator = to_int($_REQUEST['export_price_separator']);
switch($export_price_separator)
{
case 0:
$export_price_separator = ',';
break;
case 1:
default:
$export_price_separator = ';';
break;
case 2:
$separator = to_str($_REQUEST['import_price_separator_text']);
if(trim($separator) != '')
{
$export_price_separator = $separator;
}
else
{
$export_price_separator = ';';
}
break;
}
// Выводим заголовок CSV
echo '"Название раздела"'.$export_price_separator.'"CML GROUP ID идентификатор группы товаров"'.$export_price_separator.'"CML GROUP ID идентификатор родительской группы товаров"'.$export_price_separator.'"Заголовок раздела(title)"'.$export_price_separator.'"Описание раздела(description)"'.$export_price_separator.'"Ключевые слова раздела(keywords)"'.$export_price_separator.'"Описание раздела"'.$export_price_separator.'"Путь для раздела"'.$export_price_separator.'"Название товара"'.$export_price_separator.'"Описание товара"'.$export_price_separator.'"Артикул товара"'.$export_price_separator.'"Текст для товара"'.$export_price_separator.'"Вес товара"'.$export_price_separator.'"Тип товара"'.$export_price_separator.'"Количество на складе"'.$export_price_separator.'"Цена товара"'.$export_price_separator.'"Активность товара"'.$export_price_separator.'"Порядок сортировки товара"'.$export_price_separator.'"Путь к товару"'.$export_price_separator.'"Идентификатор налога для товара"'.$export_price_separator.'"Идентификатор валюты"'.$export_price_separator.'"Название продавца"'.$export_price_separator.'"Название производителя"'.$export_price_separator.'"Название единицы измерения"'.$export_price_separator.'"Заголовок страницы с товаром"'.$export_price_separator.'"Значение мета-тега description для страницы с товаром"'.$export_price_separator.'"Значение мета-тега keywords для страницы с товаром"'.$export_price_separator.'"Флаг индексации"'.$export_price_separator.'"Флаг ""Экспортировать в Яндекс.Маркет"""'.$export_price_separator.'"Флаг ""Экспортировать в Рамблер-Покупки"""'.$export_price_separator.'"Яндекс.Маркет основная расценка"'.$export_price_separator.'"Яндекс.Маркет расценка для карточек моделей"'.$export_price_separator.'"Дата"'.$export_price_separator.'"Дата публикации"'.$export_price_separator.'"Дата завершения публикации"'."\r\n";
// Начинаем экспорт групп
foreach ($array_of_groups AS $parent_key => $data)
{
foreach ($data AS $group_id)
{
$metadata = $shop->GetGroup($group_id);
if ($metadata)
{
// Генерируем идентификатор группы CommerceML
$id_group = GenCmlId($metadata['shop_groups_id']);
$id_parent_group = GenCmlId($metadata['shop_groups_parent_id']);
$shop_groups_name = str_replace('"', '""',$metadata['shop_groups_name']);
$shop_groups_description = str_replace('"', '""',$metadata['shop_groups_description']);
$shop_groups_path = $metadata['shop_groups_path'];
$shop_groups_seo_title = str_replace('"', '""',$metadata['shop_groups_seo_title']);
$shop_groups_seo_description = str_replace('"', '""',$metadata['shop_groups_seo_description']);
$shop_groups_seo_keywords = str_replace('"', '""',$metadata['shop_groups_seo_keywords']);
// Получаем название родительской группы
$group_row = $shop->GetGroup($id_parent_group);
echo '"' . $shop_groups_name . '"'.$export_price_separator.'"' . $id_group . '"'.$export_price_separator.'"' . $id_parent_group . '"'.$export_price_separator.'"'.$shop_groups_seo_title.'"'.$export_price_separator.'"'.$shop_groups_seo_description.'"'.$export_price_separator.'"'.$shop_groups_seo_keywords.'"'.$export_price_separator.'"' . str_replace('"', '""', $shop_groups_description) . '"'.$export_price_separator.'"' . $shop_groups_path .'"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'."\r\n";
}
}
}
// Начинаем экспорт товаров
while ($item_data = mysql_fetch_assoc($items_res))
{
$item_id = $item_data['shop_items_cml_id'];
if ($item_id == '')
{
$item_id = GenCmlId($item_data['shop_items_catalog_item_id']);
}
$id_parent_item = GenCmlId($item_data['shop_groups_id']);
// Получаем информацию о еденице измерения
$item_mesure_row = $shop->GetMesure($item_data['shop_mesures_id']);
// Получаем имя продавца
$seller_row = $shop->GetSeller($item_data['shop_sallers_id']);
// Получаем название производителя
$producer_row = $shop->GetProducer($item_data['shop_producers_list_id']);
// Получаем название единицы измерения
$mesures_row = $shop->GetMesure($item_data['shop_mesures_id']);
echo '""'.$export_price_separator.'"' .
$id_parent_item . '"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'"' .
$item_data['shop_items_catalog_name'] .'"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_description']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_marking'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_text']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_weight'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_type'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rest'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_price'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_is_active'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_order'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_path'] . '"'.$export_price_separator.'"' .
$item_data['shop_tax_id'] . '"'.$export_price_separator.'"' .
$item_data['shop_currency_id'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $seller_row['shop_sallers_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$producer_row['shop_producers_list_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$mesures_row['shop_mesures_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_title']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_description']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_keywords']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_indexation'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rambler_pokupki_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_bid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_cid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_date_time'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putoff_date'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putend_date'] . '"'."\r\n";
}
function GenCmlId($shop_groups_id)
{
$temp = 'ID';
$shop_groups_id = to_str($shop_groups_id);
$len = 8 - strlen($shop_groups_id);
for ($i = 0; $i < $len; $i++)
{
$temp .= '0';
}
return $temp .= $shop_groups_id;
}
exit();
?>
/**
* Система управления сайтом HostCMS v. 5.xx
* Copyright © 2005-2008 ООО "Хостмэйк" (Hostmake LLC),
*
* Обработчик экспорта данных о товарах в CSV.
*
* Файл: /admin/shop/action/export_data_csv.php
*
* @author Hostmake LLC
* @version 5.2
*/
$shop = & singleton('shop');
$kernel = & singleton('kernel');
$DataBase = & singleton('DataBase');
// Получаем родительскую группу, с котрой нужно начать экспорт
$shop_groups_parent_id = to_int($_REQUEST['shop_groups_parent_id']);
$shop_shops_id = to_int($_REQUEST['shop_shops_id']);
// Получаем список групп товаров, которые войдут в конечный XML-документ
$array_of_groups = $shop->GetGroupsTree($shop_groups_parent_id, $shop_shops_id);
// В цикле получаем список товаров, которые войдут в конечный XML-документ
$array_of_items = array();
// Запрос на получение данных о товарах для всех категориях
$query = "SELECT * FROM `shop_items_catalog_table` WHERE ";
$where_case = "(`shop_groups_id`='$shop_groups_parent_id'";
$array_of_groups_id = array();
foreach ($array_of_groups AS $parent_group_id => $array_of_child_groups)
{
if (!in_array($parent_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $parent_group_id;
$where_case .= " OR `shop_groups_id`='" . $parent_group_id . "'";
}
foreach ($array_of_child_groups AS $child_group_id => $child_data)
{
if (!in_array($child_group_id, $array_of_groups_id))
{
$array_of_groups_id[] = $child_group_id;
$where_case .= " OR `shop_groups_id`='" . $child_group_id . "'";
}
if (!in_array($child_data['shop_groups_id'], $array_of_groups_id))
{
$array_of_groups_id[] = $child_data['shop_groups_id'];
$where_case .= " OR `shop_groups_id`='" . $child_data['shop_groups_id'] . "'";
}
}
}
$where_case .= ') AND shop_shops_id=' . $shop_shops_id . ' AND `shop_items_catalog_modification_id`=0';
$query .= $where_case;
$items_res = $DataBase->query($query);
// Начинаем отправлять заголовки
header("Pragma: public");
header("Content-Description: File Transfer");
// Указываем уже определенный Content-Type
header("Content-Type: application/force-download");
// Force the download
header("Content-Disposition: attachment; filename = " . 'CSV_' .date("Y_m_d_H_i_s").'.csv'. ";");
header("Content-Transfer-Encoding: binary");
$export_price_separator = to_int($_REQUEST['export_price_separator']);
switch($export_price_separator)
{
case 0:
$export_price_separator = ',';
break;
case 1:
default:
$export_price_separator = ';';
break;
case 2:
$separator = to_str($_REQUEST['import_price_separator_text']);
if(trim($separator) != '')
{
$export_price_separator = $separator;
}
else
{
$export_price_separator = ';';
}
break;
}
// Выводим заголовок CSV
echo '"Название раздела"'.$export_price_separator.'"CML GROUP ID идентификатор группы товаров"'.$export_price_separator.'"CML GROUP ID идентификатор родительской группы товаров"'.$export_price_separator.'"Заголовок раздела(title)"'.$export_price_separator.'"Описание раздела(description)"'.$export_price_separator.'"Ключевые слова раздела(keywords)"'.$export_price_separator.'"Описание раздела"'.$export_price_separator.'"Путь для раздела"'.$export_price_separator.'"Название товара"'.$export_price_separator.'"Описание товара"'.$export_price_separator.'"Артикул товара"'.$export_price_separator.'"Текст для товара"'.$export_price_separator.'"Вес товара"'.$export_price_separator.'"Тип товара"'.$export_price_separator.'"Количество на складе"'.$export_price_separator.'"Цена товара"'.$export_price_separator.'"Активность товара"'.$export_price_separator.'"Порядок сортировки товара"'.$export_price_separator.'"Путь к товару"'.$export_price_separator.'"Идентификатор налога для товара"'.$export_price_separator.'"Идентификатор валюты"'.$export_price_separator.'"Название продавца"'.$export_price_separator.'"Название производителя"'.$export_price_separator.'"Название единицы измерения"'.$export_price_separator.'"Заголовок страницы с товаром"'.$export_price_separator.'"Значение мета-тега description для страницы с товаром"'.$export_price_separator.'"Значение мета-тега keywords для страницы с товаром"'.$export_price_separator.'"Флаг индексации"'.$export_price_separator.'"Флаг ""Экспортировать в Яндекс.Маркет"""'.$export_price_separator.'"Флаг ""Экспортировать в Рамблер-Покупки"""'.$export_price_separator.'"Яндекс.Маркет основная расценка"'.$export_price_separator.'"Яндекс.Маркет расценка для карточек моделей"'.$export_price_separator.'"Дата"'.$export_price_separator.'"Дата публикации"'.$export_price_separator.'"Дата завершения публикации"'."\r\n";
// Начинаем экспорт групп
foreach ($array_of_groups AS $parent_key => $data)
{
foreach ($data AS $group_id)
{
$metadata = $shop->GetGroup($group_id);
if ($metadata)
{
// Генерируем идентификатор группы CommerceML
$id_group = GenCmlId($metadata['shop_groups_id']);
$id_parent_group = GenCmlId($metadata['shop_groups_parent_id']);
$shop_groups_name = str_replace('"', '""',$metadata['shop_groups_name']);
$shop_groups_description = str_replace('"', '""',$metadata['shop_groups_description']);
$shop_groups_path = $metadata['shop_groups_path'];
$shop_groups_seo_title = str_replace('"', '""',$metadata['shop_groups_seo_title']);
$shop_groups_seo_description = str_replace('"', '""',$metadata['shop_groups_seo_description']);
$shop_groups_seo_keywords = str_replace('"', '""',$metadata['shop_groups_seo_keywords']);
// Получаем название родительской группы
$group_row = $shop->GetGroup($id_parent_group);
echo '"' . $shop_groups_name . '"'.$export_price_separator.'"' . $id_group . '"'.$export_price_separator.'"' . $id_parent_group . '"'.$export_price_separator.'"'.$shop_groups_seo_title.'"'.$export_price_separator.'"'.$shop_groups_seo_description.'"'.$export_price_separator.'"'.$shop_groups_seo_keywords.'"'.$export_price_separator.'"' . str_replace('"', '""', $shop_groups_description) . '"'.$export_price_separator.'"' . $shop_groups_path .'"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'."\r\n";
}
}
}
// Начинаем экспорт товаров
while ($item_data = mysql_fetch_assoc($items_res))
{
$item_id = $item_data['shop_items_cml_id'];
if ($item_id == '')
{
$item_id = GenCmlId($item_data['shop_items_catalog_item_id']);
}
$id_parent_item = GenCmlId($item_data['shop_groups_id']);
// Получаем информацию о еденице измерения
$item_mesure_row = $shop->GetMesure($item_data['shop_mesures_id']);
// Получаем имя продавца
$seller_row = $shop->GetSeller($item_data['shop_sallers_id']);
// Получаем название производителя
$producer_row = $shop->GetProducer($item_data['shop_producers_list_id']);
// Получаем название единицы измерения
$mesures_row = $shop->GetMesure($item_data['shop_mesures_id']);
echo '""'.$export_price_separator.'"' .
$id_parent_item . '"'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'""'.$export_price_separator.'"' .
$item_data['shop_items_catalog_name'] .'"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_description']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_marking'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $item_data['shop_items_catalog_text']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_weight'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_type'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rest'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_price'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_is_active'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_order'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_path'] . '"'.$export_price_separator.'"' .
$item_data['shop_tax_id'] . '"'.$export_price_separator.'"' .
$item_data['shop_currency_id'] . '"'.$export_price_separator.'"' .
str_replace('"', '""', $seller_row['shop_sallers_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$producer_row['shop_producers_list_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$mesures_row['shop_mesures_name']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_title']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_description']) . '"'.$export_price_separator.'"' .
str_replace('"', '""',$item_data['shop_items_catalog_seo_keywords']) . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_indexation'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_rambler_pokupki_allow'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_bid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_yandex_market_cid'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_date_time'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putoff_date'] . '"'.$export_price_separator.'"' .
$item_data['shop_items_catalog_putend_date'] . '"'."\r\n";
}
function GenCmlId($shop_groups_id)
{
$temp = 'ID';
$shop_groups_id = to_str($shop_groups_id);
$len = 8 - strlen($shop_groups_id);
for ($i = 0; $i < $len; $i++)
{
$temp .= '0';
}
return $temp .= $shop_groups_id;
}
exit();
?>
Авторизация