Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prestashop 1.5 module for seznam zbozi.cz feed.xml generate
<?php
/*
Prestashop 1.5 module for seznam zbozi.cz feed.xml generate
21.07.2016
Put this file in folder ./modules/feedxml-zbozi_cz
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
// Get data
$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 0);
$products = Product::getProducts((int)Context::getContext()->language->id, 0, 0, 'id_product', 'DESC' );
// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<SHOP xmlns="http://www.zbozi.cz/ns/offer/1.0">
<?php
foreach ($products AS $product)
{
$image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
echo "\t\t<SHOPITEM>\n";
echo "\t\t\t<ITEM_ID><![CDATA[".$product['id_product']."]]></ITEM_ID>\n";
echo "\t\t\t<PRODUCTNAME><![CDATA[".$product['name']."]]></PRODUCTNAME>\n";
echo "\t\t\t<PRICE_VAT><![CDATA[".Product::getPriceStatic($product['id_product'])." ]]></PRICE_VAT>\n";
echo "\t\t\t<DESCRIPTION><![CDATA[".$product['description_short']."]]></DESCRIPTION>\n";
if (is_array($image) AND sizeof($image))
{
$imageObj = new Image($image[0]['id_image']);
echo "<IMGURL><![CDATA["._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-small_default.jpg]]></IMGURL>";
}
echo "<CATEGORYTEXT>Dům, byt a zahrada | Bydlení a doplňky | Bytový textil, doplňky a dekorace | Bytový textil | Záclony a závěsy | Ubrusy</CATEGORYTEXT>";
echo "<DELIVERY_DATE>0</DELIVERY_DATE>";
echo "\t\t\t<URL><![CDATA[".str_replace('&amp;', '&', htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang)))).$affiliate."]]></URL>\n";
echo "\t\t</SHOPITEM>\n";
}
?>
</SHOP>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.