2016-05-03 12:20:54 +02:00
|
|
|
<?php
|
|
|
|
require_once('../../config/config.inc.php');
|
|
|
|
require_once('../privatesales/Sale.php');
|
|
|
|
|
|
|
|
if (!defined('_PS_BASE_URL_'))
|
|
|
|
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
|
|
|
|
|
|
|
|
|
|
|
$id_lang = Tools::getValue('id_lang');
|
|
|
|
if (!$id_lang
|
|
|
|
|| !in_array($id_lang, array(2,3))
|
|
|
|
) {
|
|
|
|
$id_lang = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
$catalog = new Catalog();
|
|
|
|
$catalog->displayContent($id_lang);
|
|
|
|
// $catalog->debug();
|
|
|
|
|
2017-04-10 16:33:42 +02:00
|
|
|
class Catalog
|
2016-05-03 12:20:54 +02:00
|
|
|
{
|
|
|
|
private $_xml;
|
|
|
|
private $_debug;
|
|
|
|
public $id_lang;
|
|
|
|
public $currentTime;
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
public function __construct(){
|
|
|
|
$this->_xml ="";
|
|
|
|
}
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
public function setContent($id_lang)
|
|
|
|
{
|
|
|
|
global $cookie;
|
|
|
|
$dom = new DomDocument();
|
|
|
|
|
|
|
|
if ($id_lang == 2) {
|
|
|
|
$site_version = 'fr';
|
|
|
|
} else if ($id_lang == 3) {
|
|
|
|
$site_version = 'es';
|
|
|
|
}
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
if (Tools::getValue('future') && Tools::getValue('future') == 1)
|
|
|
|
$sales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` DESC', NULL, $filter_type, $site_version);
|
|
|
|
else
|
|
|
|
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` DESC', NULL, $filter_type, $site_version);
|
2017-04-10 16:33:42 +02:00
|
|
|
|
|
|
|
foreach ($sales as $sale) {
|
2016-05-03 12:20:54 +02:00
|
|
|
$sql = 'SELECT value FROM '._DB_PREFIX_.'privatesale_extrafield_sale WHERE id_field = 2 AND id_lang = '.(int) $id_lang.' AND id_sale = ' . $sale->id;
|
|
|
|
if ($value = Db::getInstance()->getValue($sql)){
|
|
|
|
$sale->reduction = $value;
|
|
|
|
}else{
|
|
|
|
$sale->reduction = "Non défini";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->setXml($sales, false, $id_lang);
|
|
|
|
}
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
public function displayContent($id_lang)
|
|
|
|
{
|
|
|
|
$this->setContent($id_lang);
|
|
|
|
header('Content-Type: text/xml');
|
|
|
|
echo $this->_xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setXml($items, $rss=false, $id_lang){
|
|
|
|
$this->_xml = '<?xml version="1.0" encoding="UTF-8" ?>';
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
// Catalog
|
2017-04-10 16:33:42 +02:00
|
|
|
$this->_xml .= '<rss xmlns:atom="https://www.w3.org/2005/Atom" version="2.0"><catalogue>';
|
2016-05-03 12:20:54 +02:00
|
|
|
//Shop details
|
|
|
|
$this->_xml .= '<infos_boutique>';
|
2017-04-10 16:33:42 +02:00
|
|
|
$this->_xml .= '<logo>https://www.bebeboutik.com/img/logo.png</logo>';
|
2016-05-03 12:20:54 +02:00
|
|
|
$this->_xml .= '<nom>bebeboutik.com</nom>';
|
|
|
|
|
2017-04-10 16:33:42 +02:00
|
|
|
if (Tools::getValue('partenaire')
|
2016-05-03 12:20:54 +02:00
|
|
|
&& Tools::getValue('partenaire') == "family_deal") {
|
2017-04-10 16:33:42 +02:00
|
|
|
$this->_xml .= '<url><![CDATA[https://www.bebeboutik.com/invite/MjAxMy0wNC0z=02bj5yapRXdvJWZiVmYANWasJWdwtCdjFGdu92Y&lp=mosaique-enfant?utm_source=publicidees&utm_medium=CPL]]></url>';
|
2016-05-03 12:20:54 +02:00
|
|
|
} else {
|
2017-04-10 16:33:42 +02:00
|
|
|
$this->_xml .= '<url>https://www.bebeboutik.com</url>';
|
2016-05-03 12:20:54 +02:00
|
|
|
}
|
|
|
|
$this->_xml .= '</infos_boutique>';
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$this->_xml.='<vente>';
|
|
|
|
|
|
|
|
// $this->_xml .= '<id_vente>'.$item->id.'</id_vente>';
|
|
|
|
$this->_xml .= '<nom_vente><![CDATA['.$item->title[(int) $id_lang].']]></nom_vente>';
|
|
|
|
$this->_xml .= '<description><![CDATA['.$item->description[(int) $id_lang].']]></description>';
|
|
|
|
$this->_xml .= '<date_debut>'.$item->date_start.'</date_debut>';
|
|
|
|
$this->_xml .= '<date_fin>'.$item->date_end.'</date_fin>';
|
|
|
|
$this->_xml .= '<reduction>'.$item->reduction.'</reduction>';
|
2017-04-10 16:33:42 +02:00
|
|
|
$this->_xml .= '<image_vente>https://www.bebeboutik.com/modules/privatesales/img/'.$item->id.'/liston_'.(int) $id_lang.'.jpg</image_vente>';
|
|
|
|
|
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
$this->_xml.='</vente>';
|
|
|
|
}
|
|
|
|
$this->_xml .= '</catalogue></rss>';
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
}
|
2017-04-10 16:33:42 +02:00
|
|
|
|
2016-05-03 12:20:54 +02:00
|
|
|
}
|