$writer->startElement('root'); $writer->writeElement('creation-date', date("d/m/y : H:i:s", time())); writeOffers($items, $writer); writeOffers($itemsMetro, $writer); writeOffers($itemsNeigh, $writer); $writer->endDocument(); $writer->flush(); printLog('Finished feed for ' . $cityData['sufix']); } $stmt = $db->prepare($citiesSql); $res = $stmt->execute(); if ($res === false) { print_r($stmt->errorInfo()); die; } $stmt->setFetchMode(PDO::FETCH_ASSOC); $smallCitiesItems = $stmt->fetchAll(); $stmt->closeCursor(); $smallCitiesItems = prepareSmallCitiesItems($smallCitiesItems); printLog('Filling feed for other cities'); $writer = new XMLWriter(); $writer->openURI($file_path . 'context_rk_realty_other.xml'); $writer->startDocument('1.0', 'UTF-8'); $writer->setIndent(TRUE); $writer->startElement('root'); $writer->writeElement('creation-date', date("d/m/y : H:i:s", time())); writeOffers($smallCitiesItems, $writer); $writer->endDocument(); $writer->flush(); printLog('Finished feed for other cities'); printLog('Finished script');
foreach ($feeds as $feedName => &$feedParts) { $tempItems = array(); $items = array(); foreach ($feedParts as &$feedPart) { $search = array_keys($feedPart); array_push($search, '%select_is_dealer%', '%group_by_is_dealer%'); $replace = array_values($feedPart); $sql = str_replace($search, $replace, $sqlTemp); array_push($tempItems, getItems($sql)); array_push($replace, 'IF(l_isdealer=1,"new","used") as `type`,', ',l_isdealer'); $sql = str_replace($search, $replace, $sqlTemp); array_push($tempItems, getItems($sql)); } foreach ($tempItems as &$item) { $items = array_merge($items, $item); } prepareItems($items); printLog('Filling feed for ' . $feedName); $writer = new XMLWriter(); $writer->openURI(FILE_PATH . 'context_rk_auto_' . $feedName . '.xml'); $writer->startDocument('1.0', 'UTF-8'); $writer->setIndent(TRUE); $writer->startElement('root'); $writer->writeElement('creation-date', date('c', time())); writeOffers($items, $writer); $writer->endDocument(); $writer->flush(); printLog('Finished feed for ' . $feedName); } printLog('Finished script '); die;