97 lines
3.8 KiB
PHP
Executable File
97 lines
3.8 KiB
PHP
Executable File
<?php
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
echo "Attente de deploiement !! \n";
|
|
die();
|
|
include dirname(__FILE__).'/www/config/config.inc.php';
|
|
ini_set('memory_limit', '2G');
|
|
|
|
class XML extends SimpleXMLElement {
|
|
public function addChildAuto($name, $value=NULL) {
|
|
if(is_string($value)) {
|
|
return $this->addChildCDATA($name, $value);
|
|
} else {
|
|
return $this->addChild($name, $value);
|
|
}
|
|
}
|
|
|
|
public function addChildCDATA($name, $value=NULL) {
|
|
$new_child = $this->addChild($name);
|
|
|
|
if ($new_child !== NULL) {
|
|
$node = dom_import_simplexml($new_child);
|
|
$no = $node->ownerDocument;
|
|
$node->appendChild($no->createCDATASection($value));
|
|
}
|
|
|
|
return $new_child;
|
|
}
|
|
}
|
|
|
|
setlocale('LC_TIME', 'fr_FR.utf8');
|
|
$id_lang = 2;
|
|
|
|
// --> flux catalogue products
|
|
$xml = new XML('<?xml version="1.0" encoding="UTF-8"?><products />');
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT DISTINCT p.`id_product`, p.`price`, p.`quantity`, pl.`name`, pl.`link_rewrite`, cl.`name` as `category_name`, (sp.`reduction`) as `discount`, psl.`description`
|
|
FROM `'._DB_PREFIX_.'product` p
|
|
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON p.`id_product` = psc.`id_product`
|
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = p.`id_product`
|
|
LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON p.`id_product` = sp.`id_product`
|
|
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON psc.`id_sale` = ps.`id_sale`
|
|
LEFT JOIN `'._DB_PREFIX_.'privatesale_site_version` psv ON psv.`id_sale` = ps.`id_sale`
|
|
LEFT JOIN `'._DB_PREFIX_.'privatesale_lang` psl ON psl.`id_sale` = ps.`id_sale`
|
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ps.`id_category` = cl.`id_category`
|
|
WHERE ps.`date_start` < NOW()
|
|
AND ps.`date_end` > NOW()
|
|
AND ps.`enabled` = 1
|
|
AND psv.`version` = "fr"
|
|
AND cl.`id_lang` = '.(int) $id_lang.'
|
|
AND pl.`id_lang` = '.(int) $id_lang.'
|
|
AND psl.`id_lang` = '.(int) $id_lang.'
|
|
AND ps.`id_sale` IS NOT NULL
|
|
ORDER BY ps.`id_sale`
|
|
') as $row) {
|
|
$s = $xml->addChildAuto('product');
|
|
$s->addAttribute("id",$row['id_product']);
|
|
|
|
$s->addChildAuto('name', htmlentities($row['name']));
|
|
$s->addChildAuto('producturl', 'http://www.bebeboutik.com/?utm_source=retargeting&utm_medium=cpc&utm_campaign=criteo&lp=criteo');
|
|
|
|
/* Image Cover */
|
|
$cover = Product::getCover((int)$row['id_product']);
|
|
$link = new Link();
|
|
$smallimage = $link->getImageLink($row['link_rewrite'], (int)$cover['id_image'], 'small');
|
|
$bigimage = $link->getImageLink($row['link_rewrite'], (int)$cover['id_image'], 'thickbox');
|
|
$s->addChildAuto('smallimage', $smallimage);
|
|
$s->addChildAuto('bigimage', $bigimage);
|
|
|
|
$s->addChildAuto('description', htmlentities($row['description']));
|
|
|
|
/* Prices */
|
|
$tax_rate = Tax::getProductTaxRate((int)$row['id_product']);
|
|
$retailprice = (float)$row['price'] * (1 + ($tax_rate / 100));
|
|
$retailprice = Tools::ps_round($retailprice, 2);
|
|
$s->addChildAuto('retailprice', $retailprice);
|
|
|
|
/* Price with reduction */
|
|
$price_notax = (float)$row['price'] * (1 - (float)$row['discount']);
|
|
$price = $price_notax * (1 + ($tax_rate / 100));
|
|
$price = Tools::ps_round($price, 2);
|
|
$s->addChildAuto('price', $price);
|
|
|
|
$instock = 0;
|
|
if((int)$row['quantity']>0) {
|
|
$instock = 1;
|
|
}
|
|
$s->addChildAuto('instock', $instock);
|
|
$s->addChildAuto('category1', htmlentities($row['category_name']));
|
|
|
|
$discount = Tools::ps_round(((float)$row['discount'] * 100), 0);
|
|
$s->addChildAuto('discount', $discount);
|
|
|
|
}
|
|
/*file_put_contents(dirname(__FILE__).'/www/criteo_sales.fr.xml', $xml->asXML());*/
|
|
file_put_contents(dirname(__FILE__).'/www/modules/criteo_bbb/criteo_sales.fr.xml', $xml->asXML()); |