Bildlink endet im niergendwo
Verfasst: So 23. Jun 2013, 10:22
Hallo allerseits
Ich stehe etwas auf dem Schlauch. In meinem neu installierten Google Merchant Feed stimmt irgend etwas mit der Bild URL noch nicht so ganz.
Die Bilder werden aktuell wie folgt generiert:
Als URL sieht das dann wie folgt aus: http://www.mein-shop.com/images/product ... ded936.jpg
Das Problem ist, dass dieser Link im nirgendwo endet. Wie kann ich hier den korrekten Bildlink definieren?
Hier noch das ganze File:
Ich stehe etwas auf dem Schlauch. In meinem neu installierten Google Merchant Feed stimmt irgend etwas mit der Bild URL noch nicht so ganz.
Die Bilder werden aktuell wie folgt generiert:
Code: Alles auswählen
print_out_xml_item('g:image_link', HTTP_SERVER . DIR_WS_CATALOG . $image_dir . $products_data['products_image']);
Das Problem ist, dass dieser Link im nirgendwo endet. Wie kann ich hier den korrekten Bildlink definieren?
Hier noch das ganze File:
Code: Alles auswählen
<?php
/* export/google_xml.php
.---------------------------------------------------------------------------.
| Software: GOOGLE-Shopping XML-Export for modified-shops and xt:c 3 |
| Author: Andreas Guder |
| Version: 1.5 Standard |
| Contact: info@andreas-guder.de / http://www.andreas-guder.de |
| Copyright (c) 2013, Andreas Guder [info@andreas-guder.de] |
| GNU General Public License (Version 3) |
'--------------------------------------------------------------------------ö'
*/
require '../includes/configure.php';
error_reporting(E_ALL ^E_DEPRECATED ^E_NOTICE);
$cache_days = 0; // number of days, the xml-file will be cached before
$export_language = 2; // GET['lang'] language-id to export
$export_group = 1; // GET['group'] customers-group
$limit_page = 0; // GET['page'] number of page to export, empty or not set to export the whole database
$limit_amount = 5000; // amount of article to export if GET['page'] is set
$country_id = 0; // GET['country'] country-id, will be get shop-country-id if empty
$zone_id = 0; // GET['zone'] zone-id, will be get shop-zone-id if empty
define('LN',chr(10));
if (isset($_GET['lang']) && !empty($_GET['lang']))
$export_language = (int) $_GET['lang'];
if (isset($_GET['group']) && !empty($_GET['group']))
$export_group = (int) $_GET['group'];
if (isset($_GET['page']) && !empty($_GET['page']))
$limit_page = (int) $_GET['page'];
if (isset($_GET['cache']))
$cache_days = (int) $_GET['cache'];
if (isset($_GET['country']))
$country_id = (int) $_GET['country'];
if (isset($_GET['zone']))
$zone_id = (int) $_GET['zone'];
$cache_file_name = 'google_xml_l'.$export_language.'_g'.$export_group.'_p'.$limit_page.'_'.$country_id.$zone_id.'.xml';
define('CACHED_GOOGLE_FILE', DIR_FS_CATALOG.'export/'.$cache_file_name);
// check cache
if ($cache_days > 0)
{
if (file_exists(CACHED_GOOGLE_FILE))
{
if (time()-filemtime(CACHED_GOOGLE_FILE) < $cache_days * 24 * 3600)
{
// print out cached file
header("Content-Type: text/xml");
echo file_get_contents(CACHED_GOOGLE_FILE);
exit;
}
}
}
session_start();
$_SESSION['languages_id'] = $export_language;
require DIR_WS_INCLUDES.'database_tables.php';
require DIR_WS_INCLUDES.'filenames.php';
// require some functions anc classes
// Database
require_once (DIR_FS_INC.'xtc_db_set_charset.inc.php');
require_once (DIR_FS_INC.'xtc_db_connect.inc.php');
require_once (DIR_FS_INC.'xtc_db_close.inc.php');
require_once (DIR_FS_INC.'xtc_db_error.inc.php');
require_once (DIR_FS_INC.'xtc_db_perform.inc.php');
require_once (DIR_FS_INC.'xtc_db_query.inc.php');
require_once (DIR_FS_INC.'xtc_db_queryCached.inc.php');
require_once (DIR_FS_INC.'xtc_db_fetch_array.inc.php');
require_once (DIR_FS_INC.'xtc_db_num_rows.inc.php');
require_once (DIR_FS_INC.'xtc_db_data_seek.inc.php');
require_once (DIR_FS_INC.'xtc_db_insert_id.inc.php');
require_once (DIR_FS_INC.'xtc_db_free_result.inc.php');
require_once (DIR_FS_INC.'xtc_db_fetch_fields.inc.php');
require_once (DIR_FS_INC.'xtc_db_output.inc.php');
require_once (DIR_FS_INC.'xtc_db_input.inc.php');
require_once (DIR_FS_INC.'xtc_db_prepare_input.inc.php');
require_once (DIR_FS_INC.'xtc_get_top_level_domain.inc.php');
require_once (DIR_FS_INC.'xtc_href_link.inc.php');
require_once (DIR_FS_INC.'xtc_product_link.inc.php');
require_once (DIR_FS_INC.'xtc_category_link.inc.php');
require_once (DIR_FS_INC.'xtc_get_category_path.inc.php');
require_once (DIR_FS_INC.'xtc_get_parent_categories.inc.php');
require_once (DIR_FS_INC.'xtc_image.inc.php');
require_once (DIR_FS_INC.'xtc_get_tax_rate.inc.php');
require_once (DIR_FS_INC.'xtc_add_tax.inc.php');
require_once (DIR_FS_INC.'xtc_cleanName.inc.php');
//require_once (DIR_FS_INC.'xtc_get_products_mo_images.inc.php');
require_once (DIR_FS_INC.'xtc_set_time_limit.inc.php');
require_once (DIR_FS_INC.'xtc_parse_category_path.inc.php');
require_once (DIR_FS_INC.'xtc_get_product_path.inc.php');
require_once (DIR_FS_INC.'ecb_substr.inc.php');
require_once (DIR_FS_INC.'ecb_strlen.inc.php');
@xtc_set_time_limit(0);
// old functions
function xtDBquery($query) {
if (strtolower(DB_CACHE) == 'true') {
// echo 'cached query: '.$query.'<br />';
$result = xtc_db_queryCached($query);
} else {
// echo '::'.$query .'<br />';
$result = xtc_db_query($query);
}
return $result;
}
// make a connection to the database... now
$connection = xtc_db_connect() or die('Unable to connect to database server!');
$configuration_query = xtc_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from '.TABLE_CONFIGURATION);
while ($configuration = xtc_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
}
if (!defined('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE'))
define('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE', 'FALSE');
if (!defined('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES'))
define('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES', 'FALSE');
if (!defined('MODULE_AGI_GOOGLE_XML_STATUS') || MODULE_AGI_GOOGLE_XML_STATUS != 'TRUE')
{
header("HTTP/1.0 403 Forbidden");
exit;
}
// prepare own functions
$temp_category = array(0=>'Top');
$temp_tax = array();
$vpe_names= array();
$brand_names= array();
$google_cat=array(0=>MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY);
function buildCAT($catID, $export_language = 2)
{
$cat=array();
$tmpID=$catID;
while (getParent($catID)!=0 || $catID!=0)
{
$cat_select=xtc_db_query("SELECT `categories_name` FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE `categories_id`='".$catID."' AND `language_id`=$export_language");
$cat_data=xtc_db_fetch_array($cat_select);
$catID=getParent($catID);
$cat[]=$cat_data['categories_name'];
}
$catStr='';
for ($i=count($cat);$i>0;$i--)
{
$catStr.= ($i > 1) ? $cat[$i-1].' > ' : $cat[$i-1];
}
return $catStr;
}
function getParent($catID)
{
$parent_query=xtc_db_query("SELECT `parent_id` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$catID."'");
$parent_data=xtc_db_fetch_array($parent_query);
return $parent_data['parent_id'];
}
function getCategory($pID)
{
$categories = 0;
$categorie_query=xtc_db_query("SELECT `categories_id` FROM `".TABLE_PRODUCTS_TO_CATEGORIES."` WHERE `categories_id` > 0 AND `products_id`='".$pID."' LIMIT 0,1");
while ($categorie_data=xtc_db_fetch_array($categorie_query)) {
$categories=$categorie_data['categories_id'];
}
return $categories;
}
function getGoogleCategory($catID)
{
$parent_query = xtc_db_query("SELECT `parent_id`,`google_category` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$catID."'");
$parent_data = xtc_db_fetch_array($parent_query);
while (empty($parent_data['google_category']) && $parent_data['parent_id'] > 0)
{
$parent_query = xtc_db_query("SELECT `parent_id`,`google_category` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$parent_data['parent_id']."'");
$parent_data = xtc_db_fetch_array($parent_query);
}
return empty($parent_data['google_category']) ? '' : $parent_data['google_category'];
}
function explode_vpe_parts($vpe_text)
{
$vpe_parts = array('value' => 1, 'unit' => 'Stck.');
if (preg_match('/[0-9]{1,}/', $vpe_text, $matches))
{
$vpe_parts['value'] = $matches[0];
$vpe_parts['unit'] = trim(substr($vpe_text, strlen($vpe_parts['value'])));
}
else
$vpe_parts['unit'] = trim($vpe_text);
settype($vpe_parts['value'], 'integer');
return $vpe_parts;
}
function get_vpe_name($vpeID, $export_language = 2)
{
$vpe_query="SELECT `products_vpe_name` FROM `" . TABLE_PRODUCTS_VPE . "` WHERE `language_id`=$export_language AND `products_vpe_id`='".$vpeID."'";
$vpe_query = xtDBquery($vpe_query);
$vpe = xtc_db_fetch_array($vpe_query,true);
$tmp = array('name'=>$vpe['products_vpe_name'], 'parts' => explode_vpe_parts($vpe['products_vpe_name']));
return $tmp;
}
function get_brand_name($manID)
{
$marke = xtc_db_fetch_array(xtc_db_query("SELECT `manufacturers_name` FROM `".TABLE_MANUFACTURERS."` WHERE `manufacturers_id` = '".$manID."'"));
return $marke['manufacturers_name'];
}
function cartesian_helper($sofar,$arr,$pos,$max,&$collector)
{
$tmp = array_keys($arr);
for($i = 0; $i < count($arr[$tmp[$pos]]);$i++)
{
if($pos == $max)
$collector[] = array_merge($sofar,array($arr[$tmp[$pos]][$i]));
else
cartesian_helper(array_merge($sofar,array($arr[$tmp[$pos]][$i])),$arr,$pos+1,$max,$collector);
}
}
function cartesian($arr)
{
$bucket = array();
cartesian_helper(array(),$arr,0,count($arr)-1,$bucket);
return $bucket;
}
function calculate_shipping_from_table($s_price, $s_weight)
{
$shipping = -1;
$shippinglist = preg_split("/[:,]/" , MODULE_AGI_GOOGLE_XML_SHIPPING_LIST);
$base = (MODULE_AGI_GOOGLE_XML_SHIPPING_BASE == 'weight') ? $s_weight : $s_price;
for ($i=0; $i<sizeof($shippinglist); $i+=2)
{
if ($base <= $shippinglist[$i])
{
$shipping = $shippinglist[$i+1];
break;
}
}
if ($shipping == -1)
$shipping = 0;
return $shipping;
}
function clean_html_to_text($text, $short = 0)
{
$find = array('</p>', '<br />', '<li />', '>');
$replace = array('</p>'.chr(10), '<br />'.chr(10), '</li>'.chr(10), '> ');
$text = str_replace($find, $replace, $text);
$cleared_text = strip_tags($text);
$cleared_text = html_entity_decode($cleared_text,ENT_QUOTES,'UTF-8');
$cleared_text = str_replace(" "," ",$cleared_text);
$cleared_text = str_replace("'",", ",$cleared_text);
$cleared_text = str_replace("\n"," ",$cleared_text);
$cleared_text = str_replace("\r"," ",$cleared_text);
$cleared_text = str_replace("\t"," ",$cleared_text);
$cleared_text = str_replace("\v"," ",$cleared_text);
$cleared_text = str_replace("|",",",$cleared_text);
$cleared_text = preg_replace("/ {2,}/"," ",$cleared_text);
if ($short > 0)
{
$shorten = wordwrap($cleared_text, $short, "|");
$shorten = explode("|", $shorten);
$cleared_text = $shorten[0];
}
$cleared_text = trim($cleared_text);
return $cleared_text;
}
function print_out_xml_item($key, $value)
{
if (is_string($value) && ($value != 'TRUE' || $value != 'FALSE'))
echo '<',$key,'><![CDATA[',$value,']]></',$key,'>',LN;
else
echo '<',$key,'>',$value,'</',$key,'>',LN;
}
function print_out_product($products_data)
{
$products_description = strtolower(MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION) == 'true' ? $products_data['products_description'] : $products_data['products_short_description'];
$products_description = clean_html_to_text($products_description);
$products_name = $products_data['products_name'];
if (!empty($products_data['vpe']))
{
if (strtolower(MODULE_AGI_GOOGLE_XML_VPE_TITLE) == 'true')
$products_name .= ' ('.$products_data['vpe'].')';
if (strtolower(MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION) == 'true')
$products_description = '('.$products_data['vpe'].') '.$products_description;
}
// check condition
$condition = 'new';
if (empty($products_data['agi_google_condition']))
{
if (!empty($products_data['products_zustand']))
{
switch ($products_data['products_zustand'])
{
case 'neu':
case 'new':
$condition = 'new';
break;
case 'gebraucht':
case 'used':
$condition = 'used';
break;
case 'erneuert':
case 'refurbished':
$condition = 'refurbished';
break;
default: $condition = 'new'; break;
}
}
}
else
$condition = $products_data['agi_google_condition'];
// check availability
$availability = 'in stock';
if (strtolower(MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY) == 'true')
{
if ($products_data['products_quantity'] <= 0)
$availability = 'out of stock';
}
// calculate shipping
$s_price = $products_data['products_price'];
if ($products_data['product_has_special'])
$s_price = $products_data['specials_new_products_price'];
$shipping = 0;
if (strtolower(MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES) == 'true')
{
$shipping = calculate_shipping_from_table($s_price, $products_data['products_weight']);
}
else
{
if (defined('MODULE_SHIPPING_FREEAMOUNT_AMOUNT') && defined('MODULE_SHIPPING_FREEAMOUNT_STATUS') && strtolower(MODULE_SHIPPING_FREEAMOUNT_STATUS) == 'true' && $s_price >= MODULE_SHIPPING_FREEAMOUNT_AMOUNT)
$shipping = 0;
elseif (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER') && strtolower(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) == 'true' && $s_price > MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)
$shipping = 0;
else
$shipping = calculate_shipping_from_table($s_price, $products_data['products_weight']);
}
echo '<item>',LN;
print_out_xml_item('title', $products_name);
print_out_xml_item('description', $products_description);
if (array_key_exists('agi_google_adwords_redirect', $products_data) && !empty($products_data['agi_google_adwords_redirect']))
print_out_xml_item('link', $products_data['agi_google_adwords_redirect']);
else
print_out_xml_item('link', $products_data['link']);
print_out_xml_item('g:id', $products_data['products_id']);
if (!empty($products_data['item_group_id']))
print_out_xml_item('g:item_group_id', $products_data['item_group_id']);
print_out_xml_item('g:google_product_category', $products_data['google_category']);
print_out_xml_item('g:product_type', $products_data['category']);
$image_dir = DIR_WS_POPUP_IMAGES;
if (defined('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE') && MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE == 'info_images')
$image_dir = DIR_WS_INFO_IMAGES;
print_out_xml_item('g:image_link', HTTP_SERVER . DIR_WS_CATALOG . $image_dir . $products_data['products_image']);
$i_count = 0;
foreach ($products_data['additional_image'] as $value)
{
print_out_xml_item('g:additional_image_link', HTTP_SERVER . DIR_WS_CATALOG . $image_dir . $value);
$i_count++;
if ($i_count >= 10)
break;
}
print_out_xml_item('g:condition', $condition);
print_out_xml_item('g:availability', $availability);
print_out_xml_item('g:price', number_format($products_data['products_price'],2,'.','').' '.DEFAULT_CURRENCY);
if ($products_data['product_has_special'])
{
print_out_xml_item('g:sale_price', number_format($products_data['specials_new_products_price'],2,'.','').' '.DEFAULT_CURRENCY);
if (!empty($products_data['special_expires_date']))
{
$tmp = strtotime($products_data['special_expires_date'].' +1 day');
if ($tmp > 0)
print_out_xml_item('g:sale_price_effective_date', date('Y-m-d').'T00:00'.date('O').'/'.date('Y-m-d',$tmp).'T'.date('H:iO',$tmp));
}
}
if ($products_data['agi_google_identifier_exists'])
print_out_xml_item('g:brand', empty($products_data['brand']) ? 'Hausmarke' : $products_data['brand']);
else
print_out_xml_item('g:brand', $products_data['brand']);
if ($products_data['agi_google_identifier_exists'])
{
if (!empty($products_data['products_ean']))
print_out_xml_item('g:gtin', $products_data['products_ean']);
}
else
print_out_xml_item('g:identifier_exists', 'FALSE');
print_out_xml_item('g:mpn', !empty($products_data['products_manufacturers_model']) ? $products_data['products_manufacturers_model'] : $products_data['products_model']);
echo '<g:shipping>',LN;
print_out_xml_item('g:country', COUNTRY_CODE);
print_out_xml_item('g:service', $shipping > 0 ? 'Standard' : 'Versandkostenfrei');
print_out_xml_item('g:price', number_format($shipping,2,'.','').' '.DEFAULT_CURRENCY);
echo '</g:shipping>',LN;
if (!empty($products_data['products_weight']))
print_out_xml_item('g:shipping_weight', number_format($products_data['products_weight'],3,'.',''). 'kg');
if (!empty($products_data['agi_google_energy_efficiency']))
print_out_xml_item('g:energy_efficiency_class', $products_data['agi_google_energy_efficiency']);
if ($products_data['products_fsk18'])
print_out_xml_item('g:adult', 'TRUE');
if ($products_data['agi_google_multipack_amount'] > 1)
print_out_xml_item('g:multipack', $products_data['agi_google_multipack_amount']);
if (!empty($products_data['vpe']))
{
print_out_xml_item('g:unit_pricing_measure', $products_data['unit_pricing_measure']);
print_out_xml_item('g:unit_pricing_base_measure', $products_data['unit_pricing_base_measure']);
}
if (array_key_exists('agi_google_adwords_grouping', $products_data) && !empty($products_data['agi_google_adwords_grouping']))
print_out_xml_item('g:adwords_grouping', $products_data['agi_google_adwords_grouping']);
if (array_key_exists('agi_google_adwords_labels', $products_data) && !empty($products_data['agi_google_adwords_labels']))
{
$tmp = explode(',',$products_data['agi_google_adwords_labels']);
foreach ($tmp as $row)
{
$row = trim($row);
if (!empty($row))
print_out_xml_item('g:adwords_labels', $row);
}
}
if (array_key_exists('agi_google_adwords_redirect', $products_data) && !empty($products_data['agi_google_adwords_redirect']))
print_out_xml_item('g:adwords_redirect', $products_data['agi_google_adwords_redirect']);
if (array_key_exists('agi_google_online_only', $products_data))
print_out_xml_item('g:online_only', $products_data['agi_google_online_only'] ? 'y' : 'n');
if (array_key_exists('agi_google_excluded_destination', $products_data) && !empty($products_data['agi_google_excluded_destination']))
print_out_xml_item('g:excluded_destination', $products_data['agi_google_excluded_destination']);
if (array_key_exists('agi_google_expiration_date', $products_data) && !empty($products_data['agi_google_expiration_date']))
print_out_xml_item('g:expiration_date', $products_data['agi_google_expiration_date']);
echo '</item>',LN;
}
$tmp_bluegate = false;
if (defined('MODULE_BLUEGATE_SEO_INDEX_STATUS') && file_exists(DIR_FS_CATALOG.'inc/bluegate_seo.inc.php'))
{
if (strtolower(MODULE_BLUEGATE_SEO_INDEX_STATUS) == 'true')
{
require_once(DIR_FS_CATALOG.'inc/bluegate_seo.inc.php');
$bluegateSeo = new BluegateSeo();
$tmp_bluegate = true;
}
}
define('USE_BLUEGATE_SEO_URL',$tmp_bluegate);
// get google-attributes-options
$google_attribute_options = array();
$google_attribute_options_ids = array();
$google_attribute_options_ids_name = array();
// get customers_status
$c_check = xtc_db_query("SELECT * FROM `".TABLE_CUSTOMERS_STATUS."` WHERE `customers_status_id`=$export_group AND `language_id`=$export_language");
if (xtc_db_num_rows($c_check) == 0)
$c_check = xtc_db_query("SELECT * FROM `".TABLE_CUSTOMERS_STATUS."` WHERE `customers_status_id`=1 AND `language_id`=1");
$customers_status = xtc_db_fetch_array($c_check);
// get country-id if not set by GET
if (empty($country_id))
$country_id = STORE_COUNTRY;
if (empty($zone_id))
$zone_id = STORE_ZONE;
if (empty($zone_id) && !empty($country_id))
{
$tmp = xtc_db_query("SELECT `zone_id` FROM `".TABLE_ZONES."` WHERE `zone_country_id`=$country_id LIMIT 0,1");
$tmp = xtc_db_fetch_array($tmp);
$zone_id = $tmp['zone_id'];
}
$currency_code = DEFAULT_CURRENCY;
$tmp = xtc_db_query("SELECT `countries_iso_code_2` FROM `".TABLE_COUNTRIES."` WHERE `countries_id`=$country_id LIMIT 0,1");
$tmp = xtc_db_fetch_array($tmp);
if (!$tmp)
$tmp['countries_iso_code_2'] = 'DE';
define('COUNTRY_CODE',$tmp['countries_iso_code_2']);
// Prepare general database query
$general_query = "SELECT
p.*,
pd.products_short_description,
pd.products_name,
pd.products_description,
IFNULL(s.status, 0) AS product_has_special,
IFNULL(s.specials_new_products_price, 0) AS specials_new_products_price,
IFNULL(s.expires_date,'') AS special_expires_date
FROM
`".TABLE_PRODUCTS."` AS p
LEFT JOIN `".TABLE_PRODUCTS_DESCRIPTION."` AS pd ON pd.products_id=p.products_id AND pd.language_id=$export_language
LEFT JOIN `".TABLE_SPECIALS."` AS s ON s.products_id=p.products_id
WHERE
p.products_status=1 AND p.agi_google_export=1
";
if (strtolower(GROUP_CHECK) == 'true')
$general_query .= " AND p.group_permission_$export_group=1";
// Export FSK-Article?
if (!$customers_status['customers_fsk18_display'])
$general_query .= ' AND p.products_fsk18!=1';
// GROUP BY ORDER BY
$general_query .= ' ORDER BY p.products_id ASC';
// Export-Limit ?
if ($limit_page > 0)
{
$lstart = ($limit_page-1) * $limit_amount;
$general_query .= " LIMIT $lstart, $limit_amount";
}
$main_product_query = xtc_db_query($general_query);
$tmp = xtc_db_num_rows($main_product_query);
if (empty($tmp))
{
header("HTTP/1.0 204 No Content");
exit;
}
// Start OUTPUT
// start caching
ob_start();
echo '<?xml version="1.0" encoding="UTF-8"?>'.LN;
echo '<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">'.LN;
echo '<channel>',LN;
echo '<title><![CDATA[',STORE_NAME,']]></title>',LN;
echo '<link><![CDATA[',HTTP_SERVER,']]></link>',LN;
echo '<description><![CDATA[Google product feed created at ',date('Y-m-d H:i'),']]></description>',LN;
while ($listing = xtc_db_fetch_array($main_product_query))
{
if (empty($listing['products_image']))
continue;
$allready_print_out = false;
if (!array_key_exists($listing['products_tax_class_id'], $temp_tax))
$temp_tax[$listing['products_tax_class_id']] = xtc_get_tax_rate($listing['products_tax_class_id'], $country_id, $zone_id);
if($listing['product_has_special'] && !empty($listing['special_expires_date']))
{
$tmp = strtotime($listing['special_expires_date']);
if ($tmp < time() && $tmp>0)
$listing['product_has_special'] = 0;
if ($listing['products_price']<$listing['specials_new_products_price'])
$listing['product_has_special'] = 0;
}
// personal offer?
/*
if ($customers_status['customers_status_graduated_prices'] && strtolower(MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE) == 'true')
{
$offer_check = xtc_db_query("SELECT `personal_offer` FROM `".TABLE_PERSONAL_OFFERS_BY.$export_group."` WHERE `products_id`=".$listing['products_id']." AND `personal_offer`>0 ORDER BY `quantity` DESC LIMIT 0,1");
if (xtc_db_num_rows($offer_check) == 1)
{
$tmp = xtc_db_fetch_array($offer_check);
if (!empty($tmp['personal_offer']))
$listing['products_price'] = $tmp['personal_offer'];
}
}
*/
if ($customers_status['customers_status_show_price_tax'])
{
$listing['products_price'] = xtc_add_tax($listing['products_price'], $temp_tax[$listing['products_tax_class_id']]);
$listing['specials_new_products_price'] = xtc_add_tax($listing['specials_new_products_price'], $temp_tax[$listing['products_tax_class_id']]);
}
$products_data = $listing;
$products_data['link'] = USE_BLUEGATE_SEO_URL ? $bluegateSeo->getProductLink(xtc_product_link($listing['products_id'], $listing['products_name']),'NONSSL',$export_language) : xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($listing['products_id'],$listing['products_name']),'NONSSL', false);
if (MODULE_AGI_GOOGLE_XML_CAMPAIGN != '')
$products_data['link'] .= strpos($products_data['link'], '?') ? '&'.MODULE_AGI_GOOGLE_XML_CAMPAIGN : '?'.MODULE_AGI_GOOGLE_XML_CAMPAIGN;
if ($listing['products_vpe_status'] == 1 && $listing['products_vpe_value'] != 0.0 && $listing['products_price'] > 0)
{
if (!array_key_exists($listing['products_vpe'],$vpe_names))
$vpe_names[$listing['products_vpe']] = get_vpe_name($listing['products_vpe'], $export_language);
$tmp_price = $listing['product_has_special'] ? $listing['specials_new_products_price'] : $listing['products_price'];
$vpe_price = number_format($tmp_price * (1 / $listing['products_vpe_value']), 2,',','').' '.$currency_code.' pro '.$vpe_names[$listing['products_vpe']]['name'];
$products_data['vpe'] = $vpe_price;
$tmp = round($vpe_names[$listing['products_vpe']]['parts']['value']*$listing['products_vpe_value'],3);
$products_data['unit_pricing_measure'] = $tmp.$vpe_names[$listing['products_vpe']]['parts']['unit'];
$products_data['unit_pricing_base_measure'] = $vpe_names[$listing['products_vpe']]['parts']['value'].$vpe_names[$listing['products_vpe']]['parts']['unit'];
}
if (!empty($listing['manufacturers_id']) && !array_key_exists($listing['manufacturers_id'], $brand_names))
$brand_names[$listing['manufacturers_id']] = get_brand_name($listing['manufacturers_id'], $export_language);
$products_data['brand'] = !empty($listing['manufacturers_id']) ? $brand_names[$listing['manufacturers_id']] : '';
if (!empty($products_data['agi_google_products_brand']))
$products_data['brand'] = $products_data['agi_google_products_brand'];
$pCategory = getCategory($listing['products_id']);
if (empty($pCategory))
$pCategory = 0;
if (!array_key_exists($pCategory, $temp_category))
$temp_category[$pCategory] = buildCAT($pCategory);
$products_data['category'] = $temp_category[$pCategory];
if (!empty($pCategory))
{
if (!array_key_exists($pCategory, $google_cat))
{
$tmp = getGoogleCategory($pCategory);
$google_cat[$pCategory] = empty($tmp) ? MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY : $tmp;
}
}
else
$pCategory = 0;
$use_google_category = MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY;
if (!empty($listing['google_category']))
$use_google_category = $listing['google_category'];
elseif (!empty($google_cat[$pCategory]))
$use_google_category = $google_cat[$pCategory];
$products_data['google_category'] = $use_google_category;
$products_data['additional_image'] = array();
/*
$images = xtc_get_products_mo_images($listing['products_id']);
if ($images)
{
foreach($images as $image) {
$products_data['additional_image'][] = $image['image_name'];
}
}
*/
if (!$allready_print_out)
{
// Produkt hier ausgeben
if (defined('SHIPPING_BOX_WEIGHT'))
$products_data['products_weight'] += SHIPPING_BOX_WEIGHT;
// print out products data
print_out_product($products_data);
}
}
echo '</channel>',LN;
echo '</rss>';
// END OUTPUT
// end caching
$content = ob_get_clean();
// save cache
$fp = fopen(CACHED_GOOGLE_FILE,'w');
fputs($fp, $content);
fclose($fp);
// show cached content
header("Content-Type: text/xml");
echo $content;
?>