我有一个打开的购物车站点,该站点在一个页面上显示所有产品(如果用户选择查看此页面)。我试图将其按受欢迎程度进行排序,仅限于 1 个特定产品类别(类别 id:23),而不是当前最新添加的类别。
我知道 Opencart 已经嵌入了流行度功能,因为您可以在管理部分中查看基于“查看次数最多”和“购买次数最多”的报告。
请参阅下面的类别页面:
<?php echo $header; ?>
<div id="content">
<div class="top">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<?php if (trim($heading_title)=="Kippahs"){$heading_title="Kippah Gallery";} ?>
<?php if (trim($heading_title)=="Wedding Glass Art"){$heading_title="Wedding Glass Gallery";} ?>
<?php if (trim($heading_title)=="Judaic Art"){$heading_title="Judaica Art Gallery";} ?>
<?php if (trim($heading_title)=="Artist"){$heading_title="Meet Our Artists";} ?>
<?php if (trim($heading_title)=="Ketubahs"){$heading_title="Scroll Down to View All Our Ketubahs on One Page";} ?>
<?php if($_SERVER['QUERY_STRING']=='_route_=all-our-ketubot/' || substr($_SERVER['QUERY_STRING'],0,23)=='_route_=all-our-ketubot' || substr($_SERVER['QUERY_STRING'],0,15)=='_route_=ketubah' || substr($_SERVER['QUERY_STRING'],0,24)=='_route_=meet-our-artists' || substr($_SERVER['QUERY_STRING'],0,24)=='_route_=our-most-amazing' || substr($_SERVER['QUERY_STRING'],0,24)=='_route_=the-interfaith-k'){ ?>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<?php include("selector.php"); ?>
<?php } ?>
<div style="width:800px;">
<h1><?php echo $heading_title; ?></h1>
</div>
</div>
</div>
<div class="middle">
<table style="margin-top:-35px;margin-bottom:0px;padding:10px;">
<tr>
<?php
if($_SERVER['QUERY_STRING']!='_route_=ketubahs'){
?>
<?php if ($thumb) { ?>
<td><img class="catimg" src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" width="150" height="150" /></td>
<?php }
}
?>
<?php if ($description) { ?>
<td valign="top" class="headcat"><?php echo $description; ?></td>
<?php } ?>
</tr>
</table>
<div class="clear"> </div><!--[if lt IE 7]><br /><![endif]-->
<?php if (!$categories && !$products) { ?>
<div class="content"><?php echo $text_error; ?></div>
<?php } ?>
<?php
if($_SERVER['QUERY_STRING']!='_route_=ketubahs'){
?>
<!--<?php /* if ($categories) { */ ?> -->
<?php if ($categories && $heading_title!="Scroll Down to View All Our Ketubahs on One Page") { ?>
<table class="listC" cellspacing="7">
<?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) {
$numpages=sizeof($products);
?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%"><?php if (isset($categories[$j])) { ?>
<a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="margin-bottom: 3px;" /></a><br />
<a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>
<?php } ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<?php }
}
?>
<?php if ($products) { ?>
<!-- <div class="sort"> -->
<div class="sort" <?php if ($heading_title=="Scroll Down to View All Our Ketubahs on One Page") { echo "style='margin-top:-40px;'"; } ?> >
<div class="div1">
<select name="sort" onchange="location = this.value">
<?php foreach ($sorts as $sorts) { ?>
<?php if (($sort . '-' . $order) == $sorts['value']) { ?>
<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="div2"><?php echo $text_sort; ?></div>
</div>
<table class="listC" cellspacing="7">
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) {
$numpages=sizeof($products);
?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%">
<?php if (isset($products[$j])) { ?>
<a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" width="210px" height="210px" /></a><br /><Br />
<div style="margin-top:-15px;"><a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
<?php if($products[$j]['artist'] != 'Rosenthal, Gary' and $products[$j]['artist'] != 'Jessy Judaica' and !empty($products[$j]['artist'])){
$artist_fname=substr($products[$j]['artist'],strpos($products[$j]['artist'],",")+1);
$artist_lname=substr($products[$j]['artist'],0,strpos($products[$j]['artist'],","));
$artist_fullname=trim($artist_fname)." ".trim($artist_lname);
if (trim($products[$j]['artist'])=="Zeev") {
$artist_fullname="Ze'ev"; }
if (trim($products[$j]['artist'])=="This is not a Ketubah") {
$artist_fullname="This is not a Ketubah"; }
$artistname=str_replace(' ','-',$artist_fullname);
if (trim($artistname)=="Ze'ev") {
$artistname="Ze-ev"; }
if (trim($artistname)=="This is not a Ketubah") {
$artistname="This is not a Ketubah"; }
$artist_path='meet-our-artists/'.strtolower($artistname);
?>
<a href="<?php echo $artist_path; ?>"><span style="color:#FFF;font-weight:200;"><?php echo $artist_fullname; ?></span></a><br />
<?php } else { ?>
<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
<?php } ?>
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #00d8ff; font-weight: bold;cursor:default;"><?php echo $products[$j]['price']; ?></span>
<?php } else { ?>
<span style="color: #00d8ff; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #FAA; font-weight: bold;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
<br />
<?php if ($products[$j]['rating']) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
<?php } ?>
<a class="cart_add" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a>
<?php } ?>
<!--<a href="<?php echo $add_to_wishlist; ?>" class="wish_add" rel="nofollow"><span><?php echo $button_to_wishlist; ?>+ Favorites</span></a>-->
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
<div class="pagination" style="width:950px;text-align:right"><?php
if (($numpages-$ii)>1) {
echo "Displaying all ".($numpages-$ii)." items in this category.";
} else {
echo "Displaying 1 item in this category.";
} ?></div>
<?php } ?>
</div>
<div class="bottom">
<div class="left"></div>
<div class="right"></div>
<div class="center"></div>
</div>
</div>
<?php echo $footer; ?>
任何帮助都会很棒!
先感谢您