상품리스트에서 상품문의 갯수 (카운팅) 하는 방법 알수 있을 까요?
관련링크
본문
후기 카운팅, 댓글 카운팅은 있는데 상품문의 카운팅은 없어서 문의드립니다.
몇일을 눈이 빠지도록 시도해보았으나 적용이 안되어 도움을 받고자 문의드립니다.
혹시 알고 계신 분 있으시면 팁을 알려주시면 감사드리겠습니다.
답변 2
/skin/shop/list.10.skin.php 파일
붉은색 참조하세요. 20,30,40.skin.php 사용하시는 스킨에는 다 넣어 주셔야 나올겁니다.
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_CSS_URL.'/style.css">', 0);
?>
<!-- 상품진열 10 시작 { -->
<?php
for ($i=1; $row=sql_fetch_array($result); $i++) {
if ($this->list_mod >= 2) { // 1줄 이미지 : 2개 이상
if ($i%$this->list_mod == 0) $sct_last = ' sct_last'; // 줄 마지막
else if ($i%$this->list_mod == 1) $sct_last = ' sct_clear'; // 줄 첫번째
else $sct_last = '';
} else { // 1줄 이미지 : 1개
$sct_last = ' sct_clear';
}
// 관리자가 확인한 사용후기의 개수를 얻음
$sql = " select count(*) as cnt from `{$g5['g5_shop_item_use_table']}` where it_id = '{$row['it_id']}' and is_confirm = '1' ";
$crow= sql_fetch($sql);
$item_use_count = $crow['cnt'];
// 상품문의의 개수를 얻음
$sql = " select count(*) as cnt from `{$g5['g5_shop_item_qa_table']}` where it_id = '{$row['it_id']}' ";
$crow = sql_fetch($sql);
$item_qa_count = $crow['cnt'];
if ($i == 1) {
if ($this->css) {
echo "<ul class=\"{$this->css}\">\n";
} else {
echo "<ul class=\"sct sct_10\">\n";
}
}
echo "<li class=\"sct_li{$sct_last}\" style=\"width:{$this->img_width}px\">\n";
if ($this->href) {
echo "<div class=\"sct_img\"><a href=\"{$this->href}{$row['it_id']}\" class=\"sct_a\">\n";
}
if ($this->view_it_img) {
echo get_it_image($row['it_id'], $this->img_width, $this->img_height, '', '', stripslashes($row['it_name']))."\n";
}
if ($this->href) {
echo "</a></div>\n";
}
if ($this->view_it_icon) {
echo "<div class=\"sct_icon\">".item_icon($row)."</div>\n";
}
if ($this->view_it_id) {
echo "<div class=\"sct_id\"><".stripslashes($row['it_id'])."></div>\n";
}
if ($this->href) {
echo "<div class=\"sct_txt\"><a href=\"{$this->href}{$row['it_id']}\" class=\"sct_a\">\n";
}
if ($this->view_it_name) {
echo stripslashes($row['it_name'])."\n";
}
if ($this->href) {
echo "</a></div>\n";
}
if ($this->view_it_basic && $row['it_basic']) {
echo "<div class=\"sct_basic\">".stripslashes($row['it_basic'])."</div>\n";
}
if ($this->view_it_cust_price || $this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
if ($this->view_it_cust_price && $row['it_cust_price']) {
echo "<strike>".display_price($row['it_cust_price'])."</strike>\n";
}
if ($this->view_it_price) {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
echo "</div>\n";
}
echo "<div class=\"sct_txt\">사용후기 : ".stripslashes($item_use_count)."</div>\n";
echo "<div class=\"sct_txt\">상품문의 : ".stripslashes($item_qa_count)."</div>\n";
if ($this->view_sns) {
$sns_top = $this->img_height + 10;
$sns_url = G5_SHOP_URL.'/item.php?it_id='.$row['it_id'];
$sns_title = get_text($row['it_name']).' | '.get_text($config['cf_title']);
echo "<div class=\"sct_sns\" style=\"top:{$sns_top}px\">";
echo get_sns_share_link('facebook', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/sns_fb_s.png');
echo get_sns_share_link('twitter', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/sns_twt_s.png');
echo get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/sns_goo_s.png');
echo "</div>\n";
}
echo "</li>\n";
}
if ($i > 1) echo "</ul>\n";
if($i == 1) echo "<p class=\"sct_noitem\">등록된 상품이 없습니다.</p>\n";
?>
<!-- } 상품진열 10 끝 -->
리스트 스킨에서 추가 쿼리를 이용하시면 됩니다.
쇼핑몰은 분석을 해본적이 없어서...
list.10.skin.php를 예를 들면
10번줄 for문 안에
// 상품문의의 개수를 얻음
$sql = " select count(*) as cnt from `{$g5['g5_shop_item_qa_table']}` where it_id = '{$row['it_id']}' ";
$crow = sql_fetch($sql);
$item_qa_count = $crow['cnt'];
이렇게 쿼리를 하심 상품별 $item_qa_count에 문의 갯수를 알수 있습니다.