2016-12-04 1 views
0

나는 Opencart를 사용하고 있습니다. 검색 제품에서 검색 한 카테고리를 표시하고 싶습니다.검색 페이지에 제품 카테고리 표시

Normally: Search-> product name, 

나는 그렇게 내 결과를 보여주고 싶지 :

Search-> Category-> subcategory-> product name 

버전 : 2.1.0.1

+0

각 제품 범주를 검색 결과에 표시 하시겠습니까? – DigitCart

+0

예 .... 정확합니다 .... – ismail

+0

시도해주세요. http://stackoverflow.com/questions/40803997/opencart-to-show-category-for-each-product-in-search-results-page – DigitCart

답변

0

이동 더

catalog/controller/product/search.php 

약 행 번호 당신의 serach 컨트롤러에. 247이 코드이 하나

  $cats = $this->model_catalog_product->getCategories($result['product_id']); 
      $sep = ''; 
      $catnames = ''; 

      foreach ($cats as $cat){ 

       $catarr = $this->model_catalog_category->getCategory($cat['category_id']); 

       $catnames .= $sep.$catarr['name']; 
       $sep = ', '; 
      } 

      $data['products'][] = array(
       'product_id' => $result['product_id'], 
       'thumb'  => $image, 
       'name'  => $result['name'], 
       'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 
       'price'  => $price, 
       'special'  => $special, 
       'tax'   => $tax, 
       'rating'  => $result['rating'], 
       'href'  => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url), 
       'category' => $catnames 
      ); 

와 템플릿 파일에

  $data['products'][] = array(
       'product_id' => $result['product_id'], 
       'thumb'  => $image, 
       'name'  => $result['name'], 
       'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 
       'price'  => $price, 
       'special'  => $special, 
       'tax'   => $tax, 
       'rating'  => $result['rating'], 
       'href'  => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url) 
      ); 

에게 대체 (난 당신이 다음을 변경할 수있는 다른 테마를 사용하는 경우, 기본 테마 경로를 언급하는거야 당신은 단순히 $ 제품에게 [ '범주'] 사용하여 루프에서 호출 할 수 있습니다

catalog/view/theme/default/tempate/product/seach.tpl 

) 테마에 따라

그게 다야 !!

+0

@ismail 작동 여부 너를 위해서? –

관련 문제