<?php
header("Content-Type: text/xml; charset=utf-8");      
ini_set('max_execution_time', 0); 
$dir = '../inc/';
require_once $dir."database.php";
require_once $dir."DW_class.php";
$dw = new DWDB();
$zaman = date('d.m.Y H:i:s');
//* Seo Link oluşturma
function seo_link($link) {
$link = trim($link);
$eski = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ','\'','|','/','`','&#39;','&quot;','&',',','.','?','®',')','(','{','}','[',']');
$yeni = array('c','c','g','g','i','i','o','o','s','s','u','u','-','-','','-','','','','','','','','','','','','','','');
$seo_link = str_replace($eski,$yeni,$link);
$seo_link = strtolower($seo_link);
return $seo_link;
}
//* Seo Link oluşturma
//* Ayar Cek
$ayarcek = $dw->getRow('SELECT * FROM ayarlar WHERE id = ?', array('bindValues' => array(1)));
//* Ayar Cek
$xml ='<MerchantItems xmlns="http://www.cimri.com/schema/merchant/upload" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$results = $dw->getResults('SELECT * FROM urunler where anaurun = 0 and durum = 1 order by id');
foreach ($results as $yaz) {
//* Marka cek
$markacek = $dw->getRow('SELECT * FROM markalar WHERE id = ?', array('bindValues' => array($yaz->marka)));
//* Marka cek
//* Resim cek
$resimcek = $dw->getRow('SELECT * FROM resimler WHERE urunid = ?', array('bindValues' => array($yaz->id)));
$resimsayisi = $dw->numRows();
if($resimsayisi == 0) {
$resim = "gorselhazir.png";
} else {
$resim = $resimcek->ortaresim;
}
//* Resim cek
$kategorisi = $dw->getRow('SELECT * FROM kategoriler WHERE id = ?', array('bindValues' => array($yaz->ustkategori)));
$link = "u/".$yaz->id."/".seo_link("$kategorisi->kategori")."/".seo_link("$yaz->urun");
if ($yaz->indirimli_fiyat == "0.00") {
	$fiyati = $yaz->satis_fiyat;
} else {
	$fiyati = $yaz->indirimli_fiyat;
}
$xml.= '
<MerchantItem>
<merchantItemId>'.$yaz->id.'</merchantItemId>
<merchantItemCategoryId>'.$yaz->ustkategori.'</merchantItemCategoryId>
<merchantItemCategoryName><![CDATA['.$kategorisi->kategori.']]></merchantItemCategoryName>
<brand><![CDATA['.$markacek->marka.']]></brand>
<model><![CDATA['.$markacek->marka.']]></model>
<itemTitle><![CDATA['.$yaz->urun.']]></itemTitle>
<merchantItemField><![CDATA[]]></merchantItemField>
<itemUrl><![CDATA['.$ayarcek->sitelink.''.$yaz->seflink.']]></itemUrl>
<priceEft>'.$fiyati.'</priceEft>
<pricePlusTax>'.$fiyati.'</pricePlusTax>
<itemUrlMobile><![CDATA['.$ayarcek->sitelink.''.$yaz->seflink.']]></itemUrlMobile>
<itemImageUrl><![CDATA['.$ayarcek->sitelink.'yukleme/urun/'.$resim.']]></itemImageUrl>
<shippingFee>0.00</shippingFee>
<stockStatus>1</stockStatus>
<stockDetail><![CDATA[Ürün 3 Gün içerisinde stoklarımızda olacaktır]]></stockDetail>
<shippingDay>2</shippingDay>
<shippingDetail><![CDATA[3 iş günü içerisinde kargolanır]]></shippingDetail>
<typeOfWarranty>2</typeOfWarranty>
<warrantyPeriod>1</warrantyPeriod>
<eans>
<ean>'.$yaz->barkod.'</ean>
</eans>
</MerchantItem>
';
}
$xml .= '</MerchantItems>';
echo $xml;
error_reporting(0);
?>