コード例 #1
0
 public function getSEOMeta()
 {
     $obj = parent::getSEOMeta();
     // TODO: Change the autogenerated stub
     $title_found = false;
     $desc_found = false;
     foreach ($obj as $item) {
         if ($item->meta_name == QdSEOMeta::$META_NAME_TITLE) {
             $title_found = true;
         } else {
             if ($item->meta_name == QdSEOMeta::$META_NAME_DESCRIPTION) {
                 $desc_found = true;
             }
         }
     }
     if (!$title_found) {
         $tmp = new QdSEOMeta();
         $tmp->active = true;
         $tmp->overwrite = false;
         $tmp->seo_tpl = 1;
         $tmp->meta_name = QdSEOMeta::$META_NAME_TITLE;
         $tmp->meta_value = $this->name;
         array_push($obj, $tmp);
     }
     if (!$desc_found) {
         $tmp = new QdSEOMeta();
         $tmp->active = true;
         $tmp->overwrite = true;
         $tmp->seo_tpl = 1;
         $tmp->meta_name = QdSEOMeta::$META_NAME_DESCRIPTION;
         $price = number_format($this->_price_discount, 0, '.', ',') . ' VND';
         if ($this->discount_percent > 0) {
             $price .= ' (' . $this->discount_percent * 100 . '% OFF)';
         }
         $tmp->meta_value = substr(strip_tags($this->description), 0, 80) . '...' . $price;
         array_push($obj, $tmp);
     }
     return $obj;
 }