$conn->set_charset("utf8");
$dom = new DOMDocument("1.0", "UTF-8");
$dom->xmlStandalone = true;
$dom->formatOutput = true;
$rss = $dom->createElement("rss");
$rss->setAttribute("version", "2.0");
$rss->setAttribute("xmlns:g", "http://base.google.com/ns/1.0");
$dom->appendChild($rss);
$channel = $dom->createElement("channel");
$rss->appendChild($channel);
$channel->appendChild($dom->createElement("title", "My Deal Shop Products"));
$channel->appendChild($dom->createElement("description", "Product Feed for Facebook"));
$channel->appendChild($dom->createElement("link", "https://www.mydealsshop.foo"));
$atomlink = $dom->createElement("atom:link");
$atomlink->setAttribute("href", "https://www.mydealsshop.foo/pages/test-feed");
$atomlink->setAttribute("rel", "self");
$atomlink->setAttribute("type", "application/rss+xml");
$channel->appendChild($atomlink);
$sql = "SELECT * FROM ilanlar WHERE adi != '' AND aciklama != '' AND metrekare != '' AND oda_sayisi != '' AND emlak_durum != '' AND konut_sekli != '' AND ilan_no != '' AND konut_tipi != '' AND resim != '' AND fiyat IS NOT NULL AND durum IS NOT NULL";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$item = $dom->createElement("item");
$item->appendChild($dom->createElement("g:item_group_id", "SKU-" . $row["id"]));
$item->appendChild($dom->createElement("g:gtin", $row["emlak_durum"]));
$item->appendChild($dom->createElement("g:google_product_category", $row["konut_tipi"]));
$item->appendChild($dom->createElement("g:title", $row["adi"]));
$item->appendChild($dom->createElement("g:description", $row["aciklama"]));
$item->appendChild($dom->createElement("g:link", htmlspecialchars('https://www.SİTE.com/'.$row['seo'], ENT_QUOTES | ENT_XML1)));
$item->appendChild($dom->createElement("g:image_link", $row["resim"]));
if (!empty($row["resim"])) {
$item->appendChild($dom->createElement("g:additional_image_link", htmlspecialchars('https://www.SİTE.com/tema/genel/uploads/ilanlar/'.$row['resim'], ENT_QUOTES | ENT_XML1)));
}
$item->appendChild($dom->createElement("g:condition", $row["durum"]));
$item->appendChild($dom->createElement("g:availability", "in stock"));
$item->appendChild($dom->createElement("g
rice", $row["fiyat"] . " TRY"));$item->appendChild($dom->createElement("g:sale_price", $row["fiyat"] * 0.9 . " TRY"));
$item->appendChild($dom->createElement("g:sale_price_effective_date", "2023-05-01T00:00:00-0700/2023-05-31T23:59:59-0700"));
$item->appendChild($dom->createElement("g:brand", "My Deals Shop"));
$item->appendChild($dom->createElement("g:mpn", "SKU-" . $row["id"] . "-" . $row["ilan_no"]));
$item->appendChild($dom->createElement("g:color", $row["ilan_no"]));
$item->appendChild($dom->createElement("g:size", $row["metrekare"]));
$item->appendChild($dom->createElement("g:material", $row["konut_sekli"]));
$item->appendChild($dom->createElement("g:gender", $row["oda_sayisi"]));
$channel->appendChild($item);
}
}
header("Content-Type: application/rss+xml");
echo $dom->saveXML();
?>