130 lines
4.3 KiB
PHP
130 lines
4.3 KiB
PHP
<?php
|
|
include('../../config/config.inc.php');
|
|
include('../../app/config/parameters.php');
|
|
include('../../config/defines.inc.php');
|
|
include('../../init.php');
|
|
|
|
@ini_set('display_errors', 'off');
|
|
@error_reporting(E_ALL | E_STRICT);
|
|
|
|
class SimpleXMLElementExtended extends SimpleXMLElement
|
|
{
|
|
/**
|
|
* Add value as CData to a given XML node
|
|
*
|
|
* @param SimpleXMLElement $node SimpleXMLElement object representing the child XML node
|
|
* @param string $value A text to add as CData
|
|
* @return void
|
|
*/
|
|
private function addCDataToNode(SimpleXMLElement $node, $value = '')
|
|
{
|
|
if ($domElement = dom_import_simplexml($node))
|
|
{
|
|
$domOwner = $domElement->ownerDocument;
|
|
$domElement->appendChild($domOwner->createCDATASection("{$value}"));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Add child node with value as CData
|
|
*
|
|
* @param string $name The child XML node name to add
|
|
* @param string $value A text to add as CData
|
|
* @return SimpleXMLElement
|
|
*/
|
|
public function addChildWithCData($name = '', $value = '')
|
|
{
|
|
$newChild = parent::addChild($name);
|
|
if ($value) $this->addCDataToNode($newChild, "{$value}");
|
|
return $newChild;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Add value as CData to the current XML node
|
|
*
|
|
* @param string $value A text to add as CData
|
|
* @return void
|
|
*/
|
|
public function addCData($value = '')
|
|
{
|
|
$this->addCDataToNode($this, "{$value}");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$id_lang=(int)Context::getContext()->language->id;
|
|
$start=0;
|
|
$limit= '0';
|
|
$order_by = 'id_product';
|
|
$order_way = 'DESC';
|
|
$id_category = false;
|
|
$only_active = true;
|
|
$context = null;
|
|
$products_partial = Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category, $only_active, $context);
|
|
$products = Product::getProductsProperties($context->language->id, $products_partial);
|
|
|
|
$xml = new SimpleXMLElementExtended('<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"/>');
|
|
$xml->addChild('title', 'InterBlue xml feed');
|
|
$xml->addChild('updated', date('Y-m-d'));
|
|
foreach($products as $product) {
|
|
|
|
$price = Product::getPriceStatic($product['id_product']);
|
|
|
|
$cover = Product::getCover($product['id_product']);
|
|
$products['id_image'] = $cover['id_image'];
|
|
$link = new Link;//because getImageLInk is not static function
|
|
$imagePath = $link->getImageLink($product['link_rewrite'], $products['id_image'], 'large_default');
|
|
$thumbPath = $link->getImageLink($product['link_rewrite'], $products['id_image'], 'home_default');
|
|
|
|
$product_attribute = new Product($product['id_product']);
|
|
$combinations = $product_attribute->getAttributeCombinations($cookie->id_lang, 0,2);
|
|
|
|
$avaiable_combination_name = array();
|
|
foreach($combinations as $combination){
|
|
$avaiable_combination_name[] = $combination['attribute_name'];
|
|
}
|
|
$combination_comma_separated = implode(",", $avaiable_combination_name);
|
|
$tablicaKombinacji = explode(",",$combination_comma_separated);
|
|
|
|
|
|
$all_product_subs = Product::getProductCategoriesFull($product['id_product'], $cookie->id_lang);
|
|
$all_product_subs_path = array();
|
|
if(isset($all_product_subs) && count($all_product_subs)>0)
|
|
{
|
|
foreach($all_product_subs as $subcat)
|
|
{
|
|
$sub_category = new Category($subcat['id_category'], $cookie->id_lang);
|
|
$sub_category_children = $sub_category->getSubCategories($cookie->id_lang, $active = true);
|
|
if(count($sub_category_children)<=0)
|
|
if($subcat['id_category']!=$product['id_product']->id_category_default)//this remove the default category from the list
|
|
if(Tools::getPath($subcat['id_category'], '', true)!='')
|
|
$all_product_subs_path[] = Tools::getPath($subcat['id_category'], '', true);
|
|
}
|
|
}
|
|
|
|
$catDef = new Category($product['id_category_default'], $cookie->id_lang);
|
|
$catDefault = $catDef->name;
|
|
|
|
$katego = implode(",", $all_product_subs_path);
|
|
$tablicaKategorii = explode(",",$katego);
|
|
|
|
$productXml = $xml->addChild('produkt');
|
|
$productXml->addChild('EAN13', $product['ean13']);
|
|
$productXml->addChild('CENA_ZAKUPU', $product['wholesale_price']);
|
|
$productXml->addChild('CENA', number_format((float)$price, 2, '.', ''));
|
|
|
|
if ($product['wholesale_price'] > 0){
|
|
$marza = ($price - $product['wholesale_price']) / $product['wholesale_price'] * 100;
|
|
$productXml->addChild('MARZA', number_format((float)$marza, 2, '.', ''));
|
|
} else {
|
|
$productXml->addChild('MARZA', '0');
|
|
}
|
|
|
|
}
|
|
$xml->asXML("marze.xml");
|
|
|
|
|
|
?>
|