$xml->addAttribute('date', date('Y-m-d\TH:i:sP'));
$shop = $xml->addChild('shop');
- self::sxml_cdata($shop->addChild('name'), 'База Цветов 24');
- self::sxml_cdata($shop->addChild('company'), 'База Цветов 24');
+ $shop->addChild('name', 'База Цветов 24');
+ $shop->addChild('company', 'База Цветов 24');
$shop->addChild('url', 'https://bazacvetov24.ru');
// Добавление валюты
// Добавление категорий
$categories = $shop->addChild('categories');
- $category = $categories->addChild('category');
+ $category = $categories->addChild('category', 'Букеты');
$category->addAttribute('id', '1');
- self::sxml_cdata($category, 'Букеты');
- // Добавление информации о доставке
+ // Добавление информации о доставке???
$deliveryOptions = $shop->addChild('delivery-options');
$deliveryOption = $deliveryOptions->addChild('option');
$deliveryOption->addAttribute('cost', '200');
foreach ($productsInfo as $product) {
$offer = $offers->addChild('offer');
$offer->addAttribute('id', $product['id']);
- $offer->addAttribute('available', $product['available'] ? 'true' : 'false');
- self::sxml_cdata($offer->addChild('name'), $product['name']);
+ $offer->addAttribute('available', false);
+ $offer->addChild('name', htmlspecialchars($product['name']));
+ //TODO добавить url на конкректный букет
$offer->addChild('url', 'https://bazacvetov24.ru/flowers/' . $product['id']);
$offer->addChild('price', $product['price']);
$offer->addChild('currencyId', 'RUR');
$offerDeliveryOption->addAttribute('days', '1');
$offerDeliveryOption->addAttribute('order-before', '18');
- self::sxml_cdata($offer->addChild('description'), $product['description']);
+ $offer->addChild('description', htmlspecialchars($product['description']));
$offer->addChild('weight', $product['weight']);
$offer->addChild('qty', $product['qty']);
$offer->addChild('minorder', $product['minorder']);
+ $offer->addChild('available', $product['available'] ? 'true' : 'false');
if ($product['oldprice']) {
$offer->addChild('oldprice', $product['oldprice']);
foreach ($product['composition'] as $component) {
$consist = $offer->addChild('consist', $component['quantity']);
- $consist->addAttribute('name', $component['name']);
+ $consist->addAttribute('name', htmlspecialchars($component['name']));
$consist->addAttribute('unit', $component['unit']);
}
-
foreach ($product['pictures'] as $picture) {
$offer->addChild('picture', $picture);
}
return $xml->asXML();
}
+
private static function sxml_cdata($element, $content) {
$dom = dom_import_simplexml($element);
$cdata = $dom->ownerDocument->createCDATASection($content);