public function oldgetAction() { $c_count = 1000; $Product = new Product(); $Category = new Category(); $i = 0; $Tempval = new Tempval(); $last_update = $Tempval->get('last-update'); $last_update = $last_update['val']; $last_update = $last_update ? $last_update : time() - 24 * 60 * 60; $res = ''; $res .= '<?xml version="1.0" encoding="windows-1251"?><!DOCTYPE yml_catalog SYSTEM "shops.dtd">'; $res .= '<yml_catalog date="' . date('Y-m-d H:i', $last_update) . '">'; $res .= '<shop>'; $res .= '<name>Интернет-магазин Игрушки деткам.РУ</name>'; $res .= '<url>http://igrushki-detkam.ru</url>'; // ------------------- CURRENCY ---------------------------------------- $res .= '<currencies><currency id="RUR" rate="1"/></currencies>'; // ------------------ CATEGORIES --------------------------------------- $res .= '<categories>'; $cats = $Category->fetchAll(null, null)->toArray(); foreach ($cats as $cat) { $res .= '<category id="' . $cat['id'] . '"' . ($cat['parentId'] ? ' parentId="' . $cat['parentId'] . '"' : '') . '>' . $cat['name'] . '</category>'; } $res .= '</categories>'; // --------------------------------------------------------------------- // ------------------- OFFERS ------------------------------------------ $res .= '<offers>'; $st = $Product->get_all_by_fetch_each(); while ($toy = $st->fetch()) { $res .= '<offer id="' . $toy['id'] . '" type="vendor.model" available="true">'; $res .= '<url>' . DOMAIN_PATH . '/toy/detail/toy_id/' . $toy['id'] . '/</url>'; $res .= '<price>' . $toy['price'] . '</price>'; $res .= '<currencyId>RUR</currencyId>'; $res .= '<categoryId>' . $toy['categoryId'] . '</categoryId>'; $res .= '<picture>' . $toy['picture'] . '</picture>'; $res .= '<vendor><![CDATA[' . $toy['producer'] . ']]></vendor>'; $res .= '<model><![CDATA[' . $toy['name'] . ']]></model>'; $res .= '<description><![CDATA[' . $toy['description'] . ']]></description>'; $res .= '</offer>'; } $res .= '</offers>'; // ---------------------------------------------------------- $res .= '</shop>'; $res .= '</yml_catalog>'; $f = fopen(FTP_PATH . '/ymlcatalog.xml', 'wb'); fwrite($f, $res); fclose($f); $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); print_r('OK'); }
/** * */ public function get_all_new_products() { $ar = array(); $Tempval = new Tempval(); $last_update = $Tempval->get('last-update'); if ($last_update['val'] && ($razn = floor((time() - $last_update['val']) / 60 / 60 / 24)) <= 10) { foreach ($this->__getDbModel()->fetchAll('new between 0 and ' . (10 - $razn), 'new ASC', 200)->toArray() as $item) { $ar[] = $item['id']; } } return $ar; }
public function getAction() { $this->file_name = FTP_PATH . "/sitemap"; $c_count = 1000; $Product = new Product(); $Category = new Category(); $i = 0; $Tempval = new Tempval(); $last_update = $Tempval->get('last-update'); $last_update = $last_update['val']; $last_update = $last_update ? $last_update : time() - 24 * 60 * 60; $res = ''; /*$res .= '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';*/ // ------------------- TOYS ------------------------------- $off = 0; do { $toys = $Product->fetchAll(null, null, $c_count, $off)->toArray(); $i += count($toys); $off += $c_count; foreach ($toys as $toy) { $this->make_res(array('loc' => DOMAIN_PATH . '/toy/detail/toy_id/' . $toy['id'], 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.8')); /* $res .= '<url>'; $res .= '<loc>'.DOMAIN_PATH.'/toy/detail/toy_id/'.$toy['id'].'/</loc>'; $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>'; $res .= '<changefreq>weekly</changefreq>'; $res .= '<priority>0.8</priority>'; $res .= '</url>'; */ } } while (count($toys) > 0); // ---------------------------------------------------------- // ------------------ CATEGORIES ---------------------------- $off = 0; do { $cats = $Category->fetchAll(null, null, $c_count, $off)->toArray(); $off += $c_count; foreach ($cats as $cat) { $this->make_res(array('loc' => DOMAIN_PATH . '/category/detail-list/cat_id/' . $cat['id'], 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.5')); /* $res .= '<url>'; $res .= '<loc>'.DOMAIN_PATH.'/category/detail-list/cat_id/'.$cat['id'].'/</loc>'; $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>'; $res .= '<changefreq>weekly</changefreq>'; $res .= '<priority>0.5</priority>'; $res .= '</url>'; */ } } while (count($cats) > 0); // ---------------------------------------------------------- // ----------- MAIN PAGE ------------------------------------ $this->make_res(array('loc' => DOMAIN_PATH, 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.9'), true); /* $res .= '<url>'; $res .= '<loc>'.DOMAIN_PATH.'/</loc>'; $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>'; $res .= '<changefreq>weekly</changefreq>'; $res .= '<priority>0.9</priority>'; $res .= '</url>'; */ // ---------------------------------------------------------- //$res .='</urlset>'; /* $f = fopen(FTP_PATH.'/sitemap.xml','wb'); fwrite($f,$res); fclose($f); */ $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); print_r('OK'); }