createElement('yml_catalog'); $root->setAttribute('date', date('Y-m-d H:i')); $doc->appendChild($root); $shop = $doc->createElement('shop'); $root->appendChild($shop); $shop->appendChild($doc->createElement('name', 'Территория Тепла')); $shop->appendChild($doc->createElement('company', 'ttepla.com')); $shop->appendChild($doc->createElement('url', 'https://ttepla.com')); $shop->appendChild($doc->createElement('platform', '1C-Bitrix')); $cur = $doc->createElement('currencies'); $rub = $doc->createElement('currency'); $rub->setAttribute('id', 'RUB'); $rub->setAttribute('rate', '1'); $cur->appendChild($rub); $shop->appendChild($cur); $cats = $doc->createElement('categories'); foreach($marks['cats'] as $k => $v) { $cat = $doc->createElement('category', $v); $cat->setAttribute('id', $k); $cats->appendChild($cat); } $shop->appendChild($cats); $offers = $doc->createElement('offers'); foreach($marks['items'] as $k => $v) { $q = $v['quality']; if($q != 'Новый' && $q != '') continue; // ГМС_20012022........................ // GetMarket() не возвращает цену установленную по умолчанию // берем из нужного вида цен $db_res = CPrice::GetList( array(), array( 'PRODUCT_ID' => $v['ID'], 'CATALOG_GROUP_ID' => 2 ) ); $ar_res = $db_res->Fetch(); /////////////////////////////////////// $it = $doc->createElement('offer'); $it->setAttribute('id', $k); $it->setAttribute('available', 'true'); // ГМС_20012022......................... //$price = (int)$v['price']; $price = (int)$ar_res['PRICE']; //////////////////////////////////////// $name = htmlspecialchars($v['name']); $desc = htmlspecialchars($v['desc']); if(!$price ||preg_match('%(б/у|б\.у)%isu', $name)) { $it->setAttribute('drop', 'true'); continue; } $offers->appendChild($it); $it2 = $doc->createElement('url', 'https://ttepla.com' . $v['url'] . '?r1=yandex'); $it->appendChild($it2); $it2 = $doc->createElement('price', $price); $it->appendChild($it2); $it2 = $doc->createElement('currencyId', 'RUB'); $it->appendChild($it2); $it2 = $doc->createElement('categoryId', $v['category_id']); $it->appendChild($it2); $it2 = $doc->createElement('picture', 'https://ttepla.com' . $v['image'] . '?r1=yandex'); $it->appendChild($it2); $it2 = $doc->createElement('name', $name); $it->appendChild($it2); $it2 = $doc->createElement('description', $desc); $it->appendChild($it2); } $shop->appendChild($offers); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $xml_string = $doc->saveXML(); Header('Content-type: text/xml'); echo $xml_string;