Original SenseFuel module

This commit is contained in:
Michael RICOIS 2017-11-15 12:47:01 +01:00
parent 455cfeff90
commit 71899c1dfb
17 changed files with 917 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php
include __DIR__ . '/../../../config/settings.inc.php';
include __DIR__ . '/../../../config/config.inc.php';
include __DIR__ . '/../sensefuel.php';
if (Tools::getValue('language')) {
if (Tools::getValue('conso_only') && (int)Tools::getValue('conso_only') === 1) {
$type = SenseFuelFluxExport::SALE_TYPE_CONSO;
} else {
$type = SenseFuelFluxExport::SALE_TYPE_GLOBAL;
}
$language = Tools::getValue('language');
$file = SenseFuelFluxExport::getFilePath($language, $type);
if (file_exists($file)) {
$fp = fopen($file, 'rb');
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename=xml_data_' . $type . '_' .$language . '.xml');
header('Content-Length: ' . filesize($file));
fpassthru($fp);
} else {
echo 'false';
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
<channel>
<title><![CDATA[Bébé Boutik]]></title>
<description><![CDATA[Shop powered by PrestaShop]]></description>
<link>https://local.bebeboutik.com</link>
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
<channel>
<title><![CDATA[Bébé Boutik]]></title>
<description><![CDATA[Des réductions de -30% à -70%, tout lunivers bébés et femmes enceintes : Habillement, Eveil & Jeux, Sécurité, Santé, Sommeil, Décoration, Sorties, … Des grandes marques reconnues pour la qualité de leurs produits]]></description>
<link>https://local.bebeboutik.com</link>
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
<channel>
<title><![CDATA[Bébé Boutik]]></title>
<description><![CDATA[Negozio powered by PrestaShop]]></description>
<link>https://local.bebeboutik.com</link>
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
<channel>
<title><![CDATA[Bébé Boutik]]></title>
<description><![CDATA[Shop powered by PrestaShop]]></description>
<link>https://local.bebeboutik.com</link>
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
<channel>
<title><![CDATA[Bébé Boutik]]></title>
<description><![CDATA[Negozio powered by PrestaShop]]></description>
<link>https://local.bebeboutik.com</link>
</channel>
</rss>

View File

@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7233 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7233 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

11
modules/sensefuel/it.php Normal file
View File

@ -0,0 +1,11 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['*_9af50f05441f3f608861ce2766c9ce7d'] = 'Cercare una marca, un prodotto';
$_MODULE['*_3a8a7a8a2dbbd97c1c1519c74198112d'] = 'Cercare';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_578a0b756115fca8ed7b36423bf498eb'] = 'Aucun corner';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_ebcb38322e19ddd14dd47e3be1e4d96e'] = 'Nuovo';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_483687f76734feab12ff9691a63d5f46'] = 'Destocking';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_fc13d6b9aa0fb46eaf249a7cf2acc229'] = 'Prezzo shock';

BIN
modules/sensefuel/logo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

View File

@ -0,0 +1,533 @@
<?php
class SenseFuelFluxExport
{
const ADD_LINE_BREAKS_IN_XML = true;
const SENSEFUEL_MAX_CAT_DEPTH = 4;
const IN_STOCK_STRING = 'in stock';
const OUT_OF_STOCK_STRING = 'out of stock';
const EXPORT_FILENAME = 'export_product_flux_';
const EXPORT_FILENAME_CONSOMMABLE = 'export_product_conso_only_';
const EXPORT_EXTENSION = '.xml';
const EXPORT_SUB_DIR = '/export/';
const SALE_TYPE_CONSO = 'conso';
const SALE_TYPE_GLOBAL = 'global';
const GENERIC_BRAND = 'generique';
public $products;
public $xml;
private $content;
public static $enabledLanguageArray = array(2, 3, 5);
public function __construct($module)
{
global $cart, $cookie;
if (null === $cookie) {
$cookie = new Cookie('ps');
}
$cookie->id_lang = (int)Language::getIdByIso('fr');
$this->module = $module;
$this->products = array();
$this->xml = '';
$cart = new Cart();
$cart->id_lang = (int)Language::getIdByIso('fr');
}
private static function isShopConsoProduct($currentProduct)
{
return (int)$currentProduct['id_category'] === (int)_SHOP_CATEGORY_ROOT_;
}
private static function convertWrongChars($value)
{
$replaced = array(
0 => '/&/',
1 => '/>/',
2 => '/</',
3 => '/\'/',
4 => '/"/'
);
$replacement = array(
0 => '&amp;',
1 => '&gt;',
2 => '&lt;',
3 => '&apos;',
4 => '&quot;'
);
return preg_replace($replaced, $replacement, $value);
}
public function writeXml()
{
foreach (self::$enabledLanguageArray as $idLang) {
$language = new Language((int)$idLang);
$files = array(
self::SALE_TYPE_GLOBAL => self::getFilePath($language->iso_code, self::SALE_TYPE_GLOBAL),
self::SALE_TYPE_CONSO => self::getFilePath($language->iso_code, self::SALE_TYPE_CONSO),
);
foreach ($files as $type => $currentFile) {
if (file_exists($currentFile)) {
unlink($currentFile);
}
echo 'Getting products' . "\n";
$this->hydrateProducts($type, $language);
echo 'Getting categories' . "\n";
$this->hydrateProductCategories($language);
echo 'Getting brands' . "\n";
$this->hydrateProductBrands();
echo 'Getting menu tags' . "\n";
$this->hydrateTagCategories($language);
echo 'Getting availability' . "\n";
$this->hydrateProductStock();
try {
echo 'Creating XML' . "\n";
file_put_contents($currentFile, $this->buildXML($language));
$this->xml = "";
} catch (Exception $ex) {
Logger::AddLog("file SenseFuelFluxExport.php - " . $ex->getMessage(), 4, '0000001', 'Product', '0');
}
}
}
}
private function hydrateProducts($type, $language)
{
$this->products = array();
if ($type === self::SALE_TYPE_GLOBAL) {
$sql = '
SELECT p.`id_product`,
p.`reference`,
p.`id_manufacturer`,
pl.`name`,
pl.`description`,
pl.`link_rewrite`,
p.`ean13`,
p.`ecotax`,
i.`id_image`,
cl.`name` AS catname,
cl.`id_category`,
cl.`link_rewrite` AS cat_link_rewrite,
ps.`id_sale`,
ps.`date_start`,
ps.`date_end`,
pdl.`name` AS `delay`,
pcl.id_corner
FROM `' . _DB_PREFIX_ . 'product` p
JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (pl.id_product = p.id_product AND pl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'product_ps_cache` ppc
ON ppc.id_product = p.id_product
JOIN `' . _DB_PREFIX_ . 'privatesale` ps
ON ps.id_sale = ppc.id_sale
JOIN `' . _DB_PREFIX_ . 'privatesale_site_version` pssv
ON ps.id_sale = pssv.id_sale
JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (cl.id_category = ps.id_category AND cl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.id_product = p.id_product AND i.cover = 1)
JOIN `' . _DB_PREFIX_ . 'privatesale_delay_sale` pds
ON (pds.id_sale = ps.id_sale AND pds.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'privatesale_delay_lang` pdl
ON (pdl.id_delay = pds.id_delay AND pdl.id_lang = ' . $language->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_corner_lang` pcl
ON (pcl.id_product = p.id_product AND pcl.id_lang = ' . $language->id . ')
WHERE ps.date_start < NOW() /*maybe a larger scope could be required here*/
AND ps.date_end > NOW()
AND ps.enabled = TRUE
AND p.available_for_order = 1
AND p.active = 1
AND pssv.version = \'' . $language->iso_code . '\'
LIMIT 20000';
$this->products = Db::getInstance()->ExecuteQ($sql);
} elseif ($type === self::SALE_TYPE_CONSO) {
$sql = '
SELECT p.`id_product`,
p.`reference`,
p.`id_manufacturer`,
pl.`name`,
pl.`description`,
pl.`link_rewrite`,
p.`ean13`,
p.`ecotax`,
i.`id_image`,
cl.`name` AS catname,
cl.`id_category`,
cl.`link_rewrite` AS cat_link_rewrite,
ps.`id_sale`,
ps.`date_start`,
ps.`date_end`,
pdl.`name` AS `delay`,
pcl.id_corner
FROM `' . _DB_PREFIX_ . 'product` p
JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (pl.id_product = p.id_product AND pl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'product_ps_cache` ppc
ON ppc.id_product = p.id_product
JOIN `' . _DB_PREFIX_ . 'privatesale` ps
ON ps.id_sale = ppc.id_sale
JOIN `' . _DB_PREFIX_ . 'privatesale_site_version` pssv
ON ps.id_sale = pssv.id_sale
JOIN `' . _DB_PREFIX_ . 'privatesale_category` psc
ON (psc.id_category = ' . _SHOP_CATEGORY_ROOT_ . ' AND ps.id_sale = psc.id_sale)
JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (cl.id_category = psc.id_category AND cl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.id_product = p.id_product AND i.cover = 1)
JOIN `' . _DB_PREFIX_ . 'privatesale_delay_sale` pds
ON (pds.id_sale = ps.id_sale AND pds.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'privatesale_delay_lang` pdl
ON (pdl.id_delay = pds.id_delay AND pdl.id_lang = ' . $language->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_corner_lang` pcl
ON (pcl.id_product = p.id_product AND pcl.id_lang = ' . $language->id . ')
WHERE ps.date_start < NOW() /*maybe a larger scope could be required here*/
AND ps.date_end > NOW()
AND ps.enabled = TRUE
AND p.available_for_order = 1
AND p.active = 1
AND pssv.version = \'' . $language->iso_code . '\'
LIMIT 20000';
$this->products = Db::getInstance()->ExecuteQ($sql);
}
}
private function hydrateProductStock()
{
$productIdArray = array();
$productIdArrayResult = array();
foreach ($this->products as $currentProduct) {
$productIdArray[] = $currentProduct['id_product'];
}
$sql = 'SELECT p.`id_product`, IF(COUNT(id_product_attribute), SUM(pa.`quantity`), p.`quantity`) AS total
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` AS pa ON pa.`id_product` = p.`id_product`
WHERE p.`id_product` IN (' . implode(',', $productIdArray) . ')
GROUP BY p.`id_product`';
unset($productIdArray);
$results = Db::getInstance()->ExecuteS($sql);
if ($results) {
foreach ($results as $result) {
$productIdArrayResult[(int)$result['id_product']] = $result['total'];
}
}
$iMax = count($this->products);
for ($i = 0; $i < $iMax; $i++) {
if ($productIdArrayResult[(int)$this->products[$i]['id_product']] > 0) {
$this->products[$i]['available'] = self::IN_STOCK_STRING;
} else {
$this->products[$i]['available'] = self::OUT_OF_STOCK_STRING;
}
}
}
private function hydrateProductCategories($language)
{
$iMax = count($this->products);
for ($i = 0; $i < $iMax; $i++) {
$sql = '
SELECT cp.id_category, cl.name, c.level_depth, c.id_parent
FROM `' . _DB_PREFIX_ . 'category_product` cp
JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (cl.id_category = cp.id_category AND cl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'category` c
ON c.id_category = cl.id_category
WHERE cp.id_product = ' . $this->products[$i]['id_product'] . '
ORDER BY cp.id_category';
$categories = Db::getInstance()->ExecuteQ($sql);
$tmpArray = array();
$this->products[$i]['classic_categories'] = array();
foreach ($categories as $currentEnrichingCategory) {
$id = (int)$currentEnrichingCategory['id_category'];
$tmpArray[$id] = $currentEnrichingCategory;
$this->products[$i]['classic_categories'][(int)$currentEnrichingCategory['level_depth']] = $currentEnrichingCategory['name'];
}
$categoryTree = $this->parseTree($tmpArray, 1);
$this->products[$i]['conso_categories'] = $this->displayAllPaths($categoryTree);
unset($tmpArray);
}
}
private function hydrateTagCategories($language)
{
$sql = '
SELECT psts.id_sale,
ptl.value AS tag_name,
pstl.value AS sub_tag_name
FROM `' . _DB_PREFIX_ . 'privatesale_sub_tag_sale` psts
JOIN `' . _DB_PREFIX_ . 'privatesale_sub_tag` pst
ON pst.id_sub_tag = psts.id_sub_tag
JOIN `' . _DB_PREFIX_ . 'privatesale_tag_lang` ptl
ON (pst.id_tag_parent = ptl.id_tag AND ptl.id_lang = ' . $language->id . ')
JOIN `' . _DB_PREFIX_ . 'privatesale_sub_tag_lang` pstl
ON (psts.id_sub_tag = pstl.id_sub_tag AND pstl.id_lang = ' . $language->id . ')
WHERE 1';
$saleTags = Db::getInstance()->ExecuteQ($sql);
$tmpArray = array();
foreach ($saleTags as $saleTag) {
if (!isset($tmpArray[(int)$saleTag['id_sale']])) {
$tmpArray[(int)$saleTag['id_sale']] = array();
}
$tmpArray[(int)$saleTag['id_sale']][] = $saleTag['tag_name'] . ' > ' . $saleTag['sub_tag_name'];
}
$iMax = count($this->products);
for ($i = 0; $i < $iMax; $i++) {
if (array_key_exists($this->products[$i]['id_sale'], $tmpArray)) {
$this->products[$i]['tags'] = $tmpArray[(int)$this->products[$i]['id_sale']];
}
}
unset($tmpArray);
}
private function hydrateProductBrands()
{
$sql = '
SELECT m.name, m.id_manufacturer
FROM `' . _DB_PREFIX_ . 'manufacturer` m
WHERE m.`active` = 1';
$brands = Db::getInstance()->ExecuteQ($sql);
$tmpArray = array();
foreach ($brands as $brand) {
$tmpArray[(int)$brand['id_manufacturer']] = $brand['name'];
}
$iMax = count($this->products);
for ($i = 0; $i < $iMax; $i++) {
if (
isset($this->products[$i]['id_manufacturer']) &&
(int)$this->products[$i]['id_manufacturer'] !== 0
) {
if(array_key_exists((int)$this->products[$i]['id_manufacturer'],$tmpArray)){
$this->products[$i]['brand'] = $tmpArray[(int)$this->products[$i]['id_manufacturer']];
}else{
$this->products[$i]['brand'] = self::GENERIC_BRAND;
}
}
}
unset($tmpArray);
}
private function buildXML($language)
{
$this->buildXMLHeader($language);
$this->generateProductXML($language);
$this->buildXMLFooter();
return $this->xml;
}
private function generateProductXML($language)
{
$link = new Link();
$counter = 0;
$maxCounter = count($this->products);
$corner_list = array(
0 => $this->module->l('Aucun corner', 'sensefuelfluxexport', $language->id),
1 => $this->module->l('nouveauté', 'sensefuelfluxexport', $language->id),
2 => $this->module->l('destockage', 'sensefuelfluxexport', $language->id),
3 => $this->module->l('prix choc', 'sensefuelfluxexport', $language->id),
4 => $this->module->l('soldes', 'sensefuelfluxexport', $language->id),
);
foreach ($this->products as $currentProduct) {
echo 'Treating product ' . $counter . ' / ' . $maxCounter . "\n";
$counter++;
$this->initContent();
$this->content .= "<item>\n";
$this->addContentLine($currentProduct['id_product'], 'g:id');
$this->addContentLine($currentProduct['name'], 'g:title');
$this->addContentLine($this->applyDescriptionCleanup($currentProduct['description']), 'g:description', true);
$this->addContentLine(
$this->createProductUrl(
(int)$currentProduct['id_product'],
$currentProduct['link_rewrite'],
$currentProduct['cat_link_rewrite'],
$currentProduct['ean13'],
$language)
, 'g:link');
$this->addContentLine(
$link->getImageLink($currentProduct['link_rewrite'],
$currentProduct['id_product'] . '-' . $currentProduct['id_image'],
'large',
false)
, 'g:image_link');
$this->addContentLine(
Tools::getCurrentUrlProtocolPrefix() . 'm.' . Environment::DOMAIN_NAME . '.' . Environment::getDomainForLangId($language->id, true) . '/' .
$currentProduct['id_product'] . '-' . $currentProduct['link_rewrite'] . '.html'
, 'g:mobile_link');
$this->addContentLine($currentProduct['available'], 'g:availability');
$sale = round(Product::getPriceStatic((int)$currentProduct['id_product'], true, null, 6, null, false, false), 2);
$this->addContentLine($sale, 'g:price');
$salePrice = round(Product::getPriceStatic((int)$currentProduct['id_product'], true, null, 6, null, false, true), 2);
if ($salePrice < $sale) {
$this->addContentLine($salePrice, 'g:sale_price');
}
if (isset($currentProduct['brand'])) {
$this->addContentLine($currentProduct['brand'], 'g:brand');
}
$this->addContentLine($currentProduct['ean13'], 'g:gtin');
$this->addContentLine($currentProduct['reference'], "g:mpn");
//$this->content .= "<g:size>" . "https://support.google.com/merchants/answer/6324492" . "</g:size>";
$this->addContentLine("new", 'g:condition');
//$this->addContentLine("no", 'g:adult');
//specifics for conso shop
if (self::isShopConsoProduct($currentProduct)) {
$this->addContentLine('Consommables', 'c:sale_type');
foreach ($currentProduct['conso_categories'] as $currentCategory) {
$this->addContentLine($currentCategory, 'g:product_type');
}
} else {
//classic products in sales
if (isset($currentProduct['classic_categories'])) {
foreach ($currentProduct['classic_categories'] as $depth => $name) {
if ($depth > 1) {
$this->addContentLine($name, 'c:category' . ($depth - 2));
}
}
}
if (isset($currentProduct['tags'])) {
foreach ($currentProduct['tags'] as $product_type) {
$this->addContentLine($product_type . ' > ' . $currentProduct['catname'],
'g:product_type');
}
}
$this->addContentLine('Ventes privées', 'c:sale_type');
$this->addContentLine($currentProduct['catname'], 'c:private_sale_name');
}
$this->addContentLine(round((float)$currentProduct['ecotax'], 2), 'c:eco_tax');
$this->addContentLine($currentProduct['date_start'], 'c:private_sale_start');
$this->addContentLine($currentProduct['date_end'], 'c:private_sale_end');
$this->addContentLine($currentProduct['delay'], 'c:shipping_delay');
if (array_key_exists((int)$currentProduct['id_corner'], $corner_list) &&
(int)$currentProduct['id_corner'] > 0) {
$this->addContentLine($corner_list[(int)$currentProduct['id_corner']], 'g:custom_label_0');
}
$this->addContentLine('', 'c:shipping_cost');
$this->content .= "</item>\n";
$this->xml .= $this->content;
}
}
private function initContent()
{
$this->content = '';
}
private function createProductUrl($idProduct, $linkRewrite, $category, $ean13, $language)
{
$link = Tools::getCurrentUrlProtocolPrefix() . 'www.' . Environment::DOMAIN_NAME . '.' . Environment::getDomainForLangId($language->id, true) . '/';
if ($category && $category !== 'home') {
$link .= $category . '/';
} else {
$link .= '';
}
$link .= (int)$idProduct . '-' . $linkRewrite;
if ($ean13) {
$link .= '-' . $ean13;
}
$link .= '.html';
return $link;
}
private function addContentLine($value, $tagName, $addCData = false)
{
if (isset($value) && $value !== '') {
$this->content .= '<' . $tagName . '>' . self::convertWrongChars($value) . '</' . $tagName . '>';
if (self::ADD_LINE_BREAKS_IN_XML) {
$this->content .= "\n";
}
}
}
private function buildXMLHeader($language)
{
$meta = Meta::getMetaByPage('index', (int)($language->id));
$content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
'<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">' . "\n\n" .
'<channel>' . "\n" .
'<title><![CDATA[' . stripslashes(Configuration::get('PS_SHOP_NAME')) . ']]></title>' . "\n" .
'<description><![CDATA[' . stripslashes($meta['description']) . ']]></description>' . "\n" .
'<link>' . Tools::getProtocol() . Tools::getShopDomain() . '</link>' . "\n\n";
$this->xml .= $content;
return $content;
}
private function buildXMLFooter()
{
$content = '</channel>' . "\n" .
'</rss>';
$this->xml .= $content;
return $content;
}
private function applyDescriptionCleanup($description)
{
return trim(preg_replace('!\s+!', ' ', preg_replace("/\r|\n/", ' ', strip_tags($description))));
}
private function parseTree($categoryArray, $root = null)
{
$return = array();
# Traverse the tree and search for direct children of the root
foreach ($categoryArray as $id => $item) {
# A direct child is found
if ((int)$item['id_parent'] === (int)$root) {
# Remove item from tree (we don't need to traverse this again)
unset($categoryArray[$id]);
# Append the child into result array and parse its children
$return[] = array(
'name' => $item['name'],
'children' => $this->parseTree($categoryArray, $item['id_category'])
);
}
}
return empty($return) ? null : $return;
}
private function displayAllPaths($categoryArray, $currentPath = null)
{
$return = array();
foreach ($categoryArray as $category) {
if ($category['children'] !== null) {
if ($currentPath === null) {
$currentPath = array();
}
$currentPath[] = $category['name'];
$return = array_merge($return, $this->displayAllPaths($category['children'], $currentPath));
} else {
if ($currentPath !== null && is_array($currentPath)) {
$return[] = implode(' > ', $currentPath) . ' > ' . $category['name'];
} else {
$return[] = $category['name'];
}
}
}
return empty($return) ? null : $return;
}
public static function getFilePath($language, $type)
{
$path = _PS_MODULE_DIR_ .
'sensefuel' . self::EXPORT_SUB_DIR;
if ($type === self::SALE_TYPE_GLOBAL) {
$path .= self::EXPORT_FILENAME . $language . self::EXPORT_EXTENSION;
} elseif ($type === self::SALE_TYPE_CONSO) {
$path .= self::EXPORT_FILENAME_CONSOMMABLE . $language . self::EXPORT_EXTENSION;
}
return $path;
}
}

11
modules/sensefuel/pt.php Normal file
View File

@ -0,0 +1,11 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['*_9af50f05441f3f608861ce2766c9ce7d'] = 'Pesquisar uma marca, um produto';
$_MODULE['*_3a8a7a8a2dbbd97c1c1519c74198112d'] = 'Pesquisar';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_578a0b756115fca8ed7b36423bf498eb'] = 'Aucun corner';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_ebcb38322e19ddd14dd47e3be1e4d96e'] = 'Nouveauté';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_483687f76734feab12ff9691a63d5f46'] = 'Destockage';
$_MODULE['<{sensefuel}prestashop>sensefuelfluxexport_fc13d6b9aa0fb46eaf249a7cf2acc229'] = 'Prix Choc';

View File

@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7233 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@ -0,0 +1,30 @@
<?php
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
$_SERVER['SERVER_NAME'] = 'www.bebeboutik.com';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_PORT'] = 443;
$_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
$_SERVER['SERVER_PORT'] = 443;
global $protocol_content;
include __DIR__ . '/../../../config/settings.inc.php';
include __DIR__ . '/../../../config/config.inc.php';
if(!Tools::isCli()){
exit();
}
define('_PS_BASE_URL_', Tools::getShopDomain(true));
$protocol_content = Tools::getProtocol();
include __DIR__ . '/../sensefuel.php';
$module_instance = new sensefuel();
if ($module_instance->active) {
$senseFuelFluxExport = new SenseFuelFluxExport($module_instance);
$senseFuelFluxExport->writeXml();
}

View File

@ -0,0 +1,106 @@
<?php
include_once _PS_MODULE_DIR_ . 'sensefuel/models/SenseFuelFluxExport.php';
class SenseFuel extends Module
{
public static $ACTIVE_VERSION_ARRAY = array('fr', 'com', 'es', 'it');
public static $SETUP_VERSION_ARRAY = array();
public function __construct()
{
$this->name = 'sensefuel';
$this->tab = 'shipping_logistics';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Create Sensefuel flux');
$this->description = $this->l('Allows the creation of a google shopping flux for indexing motor sensefuel');
$this->version = '1.0';
$this->author = 'Antadis';
}
public function install()
{
if (!parent::install()
|| !$this->registerHook('footer')
|| !$this->registerHook('top')
|| !$this->registerHook('subtop')
) {
return false;
}
return true;
}
public function hookTop($params)
{
if(_PS_MOBILE_){
return false;
}
global $site_version, $page_name;
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$ACTIVE_VERSION_ARRAY, true) &&
in_array($page_name, array('index', 'category', 'product'), true)
) {
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$SETUP_VERSION_ARRAY, true) &&
in_array($page_name, array('index', 'category', 'product'), true) &&
Tools::isConnectedToBackOffice()
) {
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
return false;
}
public function hookSubTop($params)
{
if(!_PS_MOBILE_){
return false;
}
global $site_version, $page_name;
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$ACTIVE_VERSION_ARRAY , true) &&
in_array($page_name, array('index', 'category', 'product'), true)
) {
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$SETUP_VERSION_ARRAY , true) &&
in_array($page_name, array('index', 'category', 'product'), true) &&
Tools::isConnectedToBackOffice()
) {
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
return false;
}
public function hookFooter($params)
{
global $site_version, $smarty;
if (null !== $site_version &&
( in_array($site_version, self::$ACTIVE_VERSION_ARRAY, true)
|| in_array($site_version, self::$SETUP_VERSION_ARRAY, true))) {
$smarty->assign(array('sensefuelversion' => $site_version));
return self::display(__FILE__, 'views/footer.tpl');
}
return false;
}
}

View File

@ -0,0 +1,20 @@
{if isset($sensefuelversion)}
{literal}
<script type="text/javascript">
(function () {
var sf = document.createElement('script');
sf.type = 'text/javascript';
{/literal}
{if $sensefuelversion == 'com' OR $sensefuelversion == 'fr'}
{literal}sf.src = "https://tag.search.sensefuel.com/tag/bab23365-19ed-4d52-b99e-7a1fc1788a29/tag.js";{/literal}
{elseif $sensefuelversion == 'es'}
{literal}sf.src = "https://tag.search.sensefuel.com/tag/0bed0f6f-0ee4-48f0-b857-ce10d0462381/tagp.js";{/literal}
{elseif $sensefuelversion == 'it'}
{literal}sf.src = "https://tag.search.sensefuel.com/tag/c778abdd-1066-4344-b4e9-76601a55f02a/tagp.js";{/literal}
{/if}
{literal}
document.body.appendChild(sf);
})();
</script>
{/literal}
{/if}

View File

@ -0,0 +1,19 @@
{if null !== $cookie && $cookie->isLogged()}
<div id="sensefuel">
<form action="{$base_dir_ssl}search.php" id="search" role="search">
<div class="search">
<div class="search_form">
<input id="global_search" class="search_input" type="text" placeholder="{l s='Rechercher une marque, un produit' mod='sensefuel'}">
<a title="{l s='Rechercher' mod='sensefuel'}" class="search_submit" href="#"><span class="picto"></span></a>
</div>
</div>
</form>
</div>
<style>
#category #shop_category .shop_category_filter.horizontal .search {
display: none;
}
</style>
{/if}