45 lines
2.3 KiB
PHP
45 lines
2.3 KiB
PHP
<?php
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
|
|
|
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"></rss>', LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL);
|
|
$channel = $xml->addChild('channel');
|
|
$channel->addChild('title', 'Rovicky');
|
|
$channel->addChild('link', 'https://rovicky.eu/');
|
|
$channel->addChild('description', 'Rovicky - sklep internetowy z odzieżą');
|
|
$channel->addChild('language', 'pl');
|
|
$channel->addChild('generator', 'Rovicky');
|
|
$channel->addChild('lastBuildDate', date('r'));
|
|
|
|
$file = file_get_contents('https://rovicky.eu/data/export/feed10005_13d435cb09783ede936d4703.xml');
|
|
$products = new SimpleXMLElement($file);
|
|
|
|
foreach ($products->products->product as $product)
|
|
{
|
|
// echo '<pre>' . print_r($product, true) . '</pre>'; exit;
|
|
foreach ( $product->sizes->size as $size )
|
|
{
|
|
$item = $channel->addChild('item');
|
|
$item->addChild('g:id', (string)$size['code'], 'http://base.google.com/ns/1.0');
|
|
$item->addChild('title', $product->description->name);
|
|
$item->addChild('g:link', $product->card['url'], 'http://base.google.com/ns/1.0');
|
|
$item->addChild('g:image_link', $product->images->large->image[0]['url'], 'http://base.google.com/ns/1.0');
|
|
$item->addChild('g:gtin', (string)$size['code_producer'], 'http://base.google.com/ns/1.0');
|
|
$item->addChild('g:product_type', $product->category_idosell['path'], 'http://base.google.com/ns/1.0');
|
|
$item->addChild('g:condition', 'new', 'http://base.google.com/ns/1.0');
|
|
$item->addChild('g:availability', $size['available'], 'http://base.google.com/ns/1.0');
|
|
// price
|
|
$item->addChild('g:price', $size -> price['gross'] . ' PLN', 'http://base.google.com/ns/1.0');
|
|
// brand
|
|
$item->addChild('g:brand', $product -> producer['name'], 'http://base.google.com/ns/1.0');
|
|
// size
|
|
$item->addChild('g:size', $size['name'], 'http://base.google.com/ns/1.0');
|
|
// g:item_group_id
|
|
$item -> addChild('g:item_group_id', $product['id'], 'http://base.google.com/ns/1.0');
|
|
// g:shipping_weight
|
|
$item -> addChild('g:shipping_weight', $size['weight'] . ' g', 'http://base.google.com/ns/1.0');
|
|
}
|
|
}
|
|
|
|
$xml->asXml('feed-main.xml');
|
|
echo '<p>wygenerowano https://cdn.projectpro.pl/rovicky-pl/feed-main.xml</p>';
|