브랜드 검색값을 구해봅니다.

브랜드 검색값을 구해봅니다.

QA

브랜드 검색값을 구해봅니다.

본문

상품입력시 브랜드를 쓸수 있는 입력란이 있던데

사용자 페이지에서 검색브랜드검색할수 있도록 할수 있을까요?

 

이 질문에 댓글 쓰기 :

답변 1

가능합니다

 

영카트 5.3버전 기준으로..

 

/shop/search.php
if (isset($_GET['qname']) || isset($_GET['qexplan']) || isset($_GET['qid']) || isset($_GET['qbasic']) || isset($_GET['qbrand']))
    $search_all = false;

$q       = utf8_strcut(get_search_string(trim($_GET['q'])), 30, "");
$qname   = isset($_GET['qname']) ? trim($_GET['qname']) : '';
$qexplan = isset($_GET['qexplan']) ? trim($_GET['qexplan']) : '';
$qid     = isset($_GET['qid']) ? trim($_GET['qid']) : '';
$qbasic  = isset($_GET['qbasic']) ? trim($_GET['qbasic']) : '';
$qbrand  = isset($_GET['qbrand']) ? trim($_GET['qbrand']) : '';
$qcaid   = isset($_GET['qcaid']) ? preg_replace('#[^a-z0-9]#i', '', trim($_GET['qcaid'])) : '';
$qfrom   = isset($_GET['qfrom']) ? preg_replace('/[^0-9]/', '', trim($_GET['qfrom'])) : '';
$qto     = isset($_GET['qto']) ? preg_replace('/[^0-9]/', '', trim($_GET['qto'])) : '';
if (isset($_GET['qsort']))  {
    $qsort = trim($_GET['qsort']);
    $qsort = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\s]/", "", $qsort);
} else {
    $qsort = '';
}
if (isset($_GET['qorder']))  {
    $qorder = preg_match("/^(asc|desc)$/i", $qorder) ? $qorder : '';
} else {
    $qorder = '';
}

if(!($qname || $qexplan || $qid || $qbasic || $qbrand))
    $search_all = true;

// 검색범위 checkbox 처리
$qname_check = false;
$qexplan_check = false;
$qid_check = false;
$qbasic_check = false;

if($search_all) {
    $qname_check = true;
    $qexplan_check = true;
    $qid_check = true;
    $qbasic_check = true;
    $qbrand_check = true;
} else {
    if($qname)
        $qname_check = true;
    if($qexplan)
        $qexplan_check = true;
    if($qid)
        $qid_check = true;
    if($qbasic)
        $qbasic_check = true;
    if($qbrand)
        $qbrand_check = true;

}

if ($q) {
    $arr = explode(" ", $q);
    $detail_where = array();
    for ($i=0; $i<count($arr); $i++) {
        $word = trim($arr[$i]);
        if (!$word) continue;

        $concat = array();
        if ($search_all || $qname)
            $concat[] = "a.it_name";
        if ($search_all || $qexplan)
            $concat[] = "a.it_explan2";
        if ($search_all || $qid)
            $concat[] = "a.it_id";
        if ($search_all || $qbasic)
            $concat[] = "a.it_basic";
        if ($search_all || $qbrand)
            $concat[] = "a.it_brand";

        $concat_fields = "concat(".implode(",' ',",$concat).")";

        $detail_where[] = $concat_fields." like '%$word%' ";

        // 인기검색어
        insert_popular($concat, $word);
    }

    $where[] = "(".implode(" and ", $detail_where).")";
}

 

 

./skin/shop/search.skin.php

 


            <div class="ssch_right">
                <strong class="sound_only">검색범위</strong>
                <input type="checkbox" name="qname" id="ssch_qname" value="1" <?php echo $qname_check?'checked="checked"':'';?>> <label for="ssch_qname">상품명</label>
                <input type="checkbox" name="qexplan" id="ssch_qexplan" value="1" <?php echo $qexplan_check?'checked="checked"':'';?>> <label for="ssch_qexplan">상품설명</label>
                <input type="checkbox" name="qbasic" id="ssch_qbasic" value="1" <?php echo $qbasic_check?'checked="checked"':'';?>> <label for="ssch_qbasic">기본설명</label>
                <input type="checkbox" name="qid" id="ssch_qid" value="1" <?php echo $qid_check?'checked="checked"':'';?>> <label for="ssch_qid">상품코드</label>
                <input type="checkbox" name="qbrand" id="ssch_brand" value="1" <?php echo $qbrand_check?'checked="checked"':'';?>> <label for="ssch_brand">브랜드</label>
                <strong class="sound_only">상품가격 (원)</strong>
                <label for="ssch_qfrom" class="sound_only">최소 가격</label>
                <input type="text" name="qfrom" value="<?php echo $qfrom; ?>" id="ssch_qfrom" class="ssch_input" size="10"> 원 ~
                <label for="ssch_qto" class="sound_only">최대 가격</label>
                <input type="text" name="qto" value="<?php echo $qto; ?>" id="ssch_qto" class="ssch_input" size="10"> 원
            </div>
            <div class="ssch_left">
                <label for="ssch_q" class="sound_only" >검색어</label>
                <input type="text" name="q" value="<?php echo $q; ?>" id="ssch_q" class="ssch_input" size="40" maxlength="30" placeholder="검색어">
                <input type="submit" value="검색" class="btn_submit">
            </div>
        </div>

 

 

강조된 부분을 추가하시면 됩니다.

 

감사합니다.
덕분에 깔끔하게 잘 해결 됬습니다.!
한가지만 더 여쭤뵈도 될까요?
상품 상세페이지에서 브랜드 값이 출력이 되는 부분에 검색결과 리스트 결과를 연결해줄수 있을까요?

답변을 작성하시기 전에 로그인 해주세요.
전체 180 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT