예제 #1
0
 /**
  * @param $searchString
  * @return array|bool
  */
 public function suggestSearchProduct($searchString)
 {
     $productModel = new productModel();
     $tagModel = new tagModel();
     if ($searchString) {
         $data = array();
         $products = $productModel->suggestSearchProduct($searchString);
         if ($products) {
             foreach ($products as &$product) {
                 $product->slug = str_slug($product->name);
                 $product->priceShow = formatMoney($product->sell_price - $product->discount);
             }
         }
         $data['products'] = $products->toArray();
         $tags = $tagModel->suggestSearchProduct($searchString);
         if ($tags) {
             foreach ($tags as &$tag) {
                 $tag->slug = str_slug($tag->name);
             }
         }
         $data['tags'] = $tags->toArray();
         return $data;
     } else {
         return false;
     }
 }
예제 #2
0
 public function toggleStatusRelation($tagId, $typeId, $parentId)
 {
     $tagModel = new tagModel();
     $tagRelation = $tagModel->getTagRelation($tagId, $typeId);
     if ($tagRelation->status == TAG_RELATION_STATUS_INACTIVE) {
         if ($parentId) {
             $parentTagRelation = $tagModel->getTagRelation($parentId, $typeId);
             if ($parentTagRelation->status == TAG_RELATION_STATUS_INACTIVE) {
                 return false;
             }
         }
         $tagModel->updateTagRelationOrder($tagId, $typeId, ['status' => TAG_RELATION_STATUS_ACTIVE]);
     }
     if ($tagRelation->status == TAG_RELATION_STATUS_ACTIVE) {
         $tagModel->updateTagRelationOrder($tagId, $typeId, ['status' => TAG_RELATION_STATUS_INACTIVE]);
         $tagArr = [];
         $subTags = $this->getAllChildTag($tagId, $tagArr, $typeId, TAG_RELATION_STATUS_ACTIVE);
         foreach ($subTags as $subTag) {
             $tagModel->updateTagRelationOrder($subTag, $typeId, ['status' => TAG_RELATION_STATUS_INACTIVE]);
         }
     }
     return true;
 }