83 lines
2.8 KiB
PHP
Executable File
83 lines
2.8 KiB
PHP
Executable File
<?php
|
|
@ini_set('display_errors', 'on');
|
|
require_once('../../config/config.inc.php');
|
|
require_once('../privatesales/privatesales.php');
|
|
|
|
if (!defined('_PS_BASE_URL_'))
|
|
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
|
|
|
|
|
$catalog = new Catalog();
|
|
$catalog->displayContent();
|
|
// $catalog->debug();
|
|
|
|
class Catalog{
|
|
private $_xml;
|
|
private $_debug;
|
|
public $id_lang;
|
|
public $currentTime;
|
|
|
|
public function __construct(){
|
|
$this->_xml ="";
|
|
}
|
|
|
|
public function setContent(){
|
|
global $cookie;
|
|
$dom = new DomDocument();
|
|
|
|
$sales = SaleCore::getSales("current",0,TRUE,FALSE,TRUE,'position','ASC',FALSE,FALSE,null);
|
|
// echo "<pre>";
|
|
// print_r($sales);
|
|
// echo "</pre>";
|
|
$this->setXml($sales, false);
|
|
}
|
|
|
|
public function displayContent(){
|
|
$this->setContent();
|
|
$this->createXML();
|
|
header('Content-type: text/xml');
|
|
echo $this->_xml;
|
|
}
|
|
|
|
public function setXml($items, $rss=false){
|
|
$this->_xml = '<?xml version="1.0" encoding="iso-8859-1" ?>'."\n";
|
|
$this->_xml .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
|
|
|
|
// Catalog
|
|
$this->_xml .= '<channel>'."\n";
|
|
//Shop details
|
|
$this->_xml .= '<title>Privilège de marque</title>'."\n";
|
|
$this->_xml .= '<description>Toutes les marques des PROS de l\'hôtellerie restauration en ventes privées.</description>'."\n";
|
|
$this->_xml .= '<link>http://www.privilegedemarque.com/</link>'."\n";
|
|
$this->_xml .= '<atom:link href="http://www.privilegedemarque.com/modules/cron/fluxVP.xml" rel="self" type="application/rss+xml"/>'."\n";
|
|
foreach ($items as $item){
|
|
$this->_xml.='<item>'."\n";
|
|
|
|
// $this->_xml .= '<id_vente>'.$item->id.'</id_vente>';
|
|
$this->_xml .= '<title><![CDATA['.$item->title.']]></title>'."\n";
|
|
$this->_xml .= '<subtitle><![CDATA['.$item->subtitle.']]></subtitle>'."\n";
|
|
$this->_xml .= '<description><![CDATA['.str_replace(array("«","»"),"\"",$item->description).']]></description>'."\n";
|
|
$this->_xml .= '<date_debut>'.$item->date_start.'</date_debut>'."\n";
|
|
$this->_xml .= '<date_fin>'.$item->date_end.'</date_fin>'."\n";
|
|
$this->_xml .= '<reduction>'.$item->percent.'</reduction>'."\n";
|
|
$this->_xml .= '<image>'._PS_BASE_URL_.'/modules/privatesales/img/'.$item->id.'/current/'.$item->id.'_'.Context::getContext()->language->id.'.jpg</image>'."\n";
|
|
$this->_xml .= '<logo>'._PS_BASE_URL_.'/modules/privatesales/img/'.$item->id.'/logo/'.$item->id.'_'.Context::getContext()->language->id.'.jpg</logo>'."\n";
|
|
$this->_xml .= '<link>'.$item->link.'</link>'."\n";
|
|
|
|
$this->_xml.='</item>'."\n";
|
|
}
|
|
$this->_xml .= '</channel>'."\n".'</rss>';
|
|
|
|
}
|
|
|
|
public function createXML(){
|
|
$fp = fopen("fluxVP.xml", "w+");
|
|
fwrite($fp, utf8_decode($this->_xml));
|
|
fclose($fp);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|