示例#1
0
 public function index()
 {
     set_time_limit(6000);
     if (!isset($this->request->query['brand']) or !$this->request->query['brand']) {
         echo 'Укажите производителя';
         exit;
     }
     $id = $this->CarType->field('CarType.id', array('CarType.slug' => Translit::convert($this->request->query['brand'], true)));
     if (!$id) {
         echo 'Производитель не найден';
         exit;
     }
     try {
         $this->ZzapParser->saveSubsections($id);
         echo 'all info saved succesfully';
         exit;
     } catch (Exception $e) {
         echo 'Error: ' . $e->getMessage();
         exit;
     }
 }
示例#2
0
 private function saveSections($parsedSections, $brandId)
 {
     $modelList = $this->getModelsListForBrand($brandId);
     foreach ($parsedSections as $modelName => $sectionList) {
         $modelName = trim($modelName);
         $modelName = str_replace(' ', '', $modelName);
         $catId = array_search(Translit::convert($modelName, true), $modelList);
         if (!$catId) {
             $data['CarSubtype'] = array('object_type' => 'CarSubtype', 'title' => $modelName, 'slug' => Translit::convert($modelName, true), 'cat_id' => $brandId);
             $this->CarSubtype->saveAll($data);
             $catId = $this->CarSubtype->id;
         }
         $existSubsection = $this->getExistSubsections($catId);
         foreach ($sectionList as $section) {
             $section = trim($section);
             $sectionId = array_search(Translit::convert($section, true), $existSubsection);
             if (!$sectionId) {
                 $saveData['CarSubsection'] = array('object_type' => 'CarSubsection', 'cat_id' => $catId, 'title' => $section, 'slug' => Translit::convert($section, true));
                 $this->CarSubsection->saveAll($saveData);
             }
         }
     }
 }
示例#3
0
 public function update3()
 {
     App::uses('Translit', 'Article.Vendor');
     // $this->PHTranslit = new PHTranslitHelper($this->view);
     $conditions = array('object_type' => 'Product');
     $page = 1;
     $limit = 10;
     $order = 'SiteArticle.id';
     while ($articles = $this->SiteArticle->find('all', compact('conditions', 'page', 'limit', 'order'))) {
         $page++;
         foreach ($articles as $article) {
             $data = $article['SiteArticle'];
             $data['page_id'] = Translit::convert($data['title_rus'] . '-' . $data['detail_num'], true);
             $this->SiteArticle->save(array('id' => $data['id'], 'page_id' => $data['page_id']));
         }
     }
 }