Example #1
0
 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');
 }