aelalfy1989 Posted January 6, 2010 Posted January 6, 2010 Hey Everyone, I was wondering if someone can help me with this one as well. I want to create an infobox similar to my "new to the store" and "top seller" thats called "popular accessories". Basically, it takes the products from my "accessories" category only. I have 3 categories but I want it to take the most popluar products from my "accessories category" Even from the subcategories of that category. Bascially it would find the most popular accessories in that category based on: 1) top sellers 2) most view 3) most clicked 4) any method that you guys can think of. Here is my code so far. Thanks for the help in advance, and hope someone can help. <?php //$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = $current_category_id and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by cd.categories_name ASC, RAND(1000), sort_order, cd.categories_name"); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = 5 and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by cd.categories_name ASC, RAND(1000), sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $rows = 0; $p_cnt = tep_db_query("SELECT COUNT(*) AS total FROM products_to_categories AS pc, products_description AS pd WHERE pc.categories_id = ".$categories['categories_id']." AND pc.products_id = pd.products_id AND pd.language_id = 1"); $getSize = tep_db_fetch_array($p_cnt); if($getSize['total'] <= 0) continue; $p_load = tep_db_query("SELECT pc.products_id, pd.products_name FROM products_to_categories AS pc, products_description AS pd WHERE pc.categories_id = ".$categories['categories_id']." AND pc.products_id = pd.products_id AND pd.language_id = 1"); ?> <!-- best_sellers //--> <tr> <td valign="top"> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => '<strong>Popular Accessories</strong>'); new infoBoxHeading($info_box_contents, false, false); tep_draw_heading_top_3(); $bestsellers_list = '<ul>'; while($best_sellers = tep_db_fetch_array($p_load)) { $rows++; if ($count ==0 ) $kk=' class="prod_new_box" style="line-height:20px"'; else $kk=' class="prod_new_box" style="line-height:20px"'; if ($kk!='') { $bestsellers_list .= '<li'.$kk.'><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . substr($best_sellers['products_name'], 0, MAX_DESCR_BESTS) . '</a></li>'; } else { $bestsellers_list .= '<li'.$kk.'><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . substr($best_sellers['products_name'],0,MAX_DESCR_BESTS) . '</a></li>'; } } $bestsellers_list .= '</ul>'; $info_box_contents = array(); $info_box_contents[] = array('text' => $bestsellers_list); new infoBox($info_box_contents); tep_draw_heading_bottom_3(); ?> </td> </tr> <tr><td> </td></tr> <?php } ?> Thank you in advance, AE
Recommended Posts
Archived
This topic is now archived and is closed to further replies.