equies Posted November 4, 2002 Posted November 4, 2002 Hi all, I am trying to replace the 'New Products For Month' in the main section of the default page with the 'Bestsellers' whilst keeping the presentation of the section identical. Problem is I cannot even find the reference to include 'New Products' on default.php? I've searched the forums; someone must have wanted to do this surely :?: Couldn't find anything :? Can anyone help me out with this one? Thanks
Guest Posted November 4, 2002 Posted November 4, 2002 If anyone helps you can you please let me know.
mlulm Posted November 17, 2002 Posted November 17, 2002 How can we change the default page and the category pages to show the bestsellers in the same format as the Whats New that is normally on the default page?
Guest Posted November 22, 2002 Posted November 22, 2002 Here's what I did to make this happen (there's a number of small changes, but nothing major so I didn't submit it as a contrib) First, create a file called best_sellers.php and put it in catalog/includes/modules: <?php /* $Id: best_sellers.php,v 1.32 2002/11/22 20:28:07 dgw_ Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ ?> <!-- best_sellers //--> <?php $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_HOT_ITEMS, strftime('%B'))); new contentBoxHeading($info_box_contents); $best_sellers_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_ordered from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_NEW_PRODUCTS); $info_box_contents = array(); $row = 0; $col = 0; while ($best_sellers = tep_db_fetch_array($best_sellers_query)) { $best_sellers['products_name'] = tep_get_products_name($best_sellers['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $best_sellers['products_image'], $best_sellers['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a><br>' . $currencies->display_price($best_sellers['products_price'], tep_get_tax_rate($best_sellers['products_tax_class_id']))); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); ?> <!-- best_sellers_eof //--> Next, open catalog/default.php and change the last occurance of: <?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?> To: <?php include(DIR_WS_MODULES . FILENAME_BEST_SELLERS); ?> By changing the last occurance only, it will display your bestsellers on the main page, but new products will be displayed on the category pages. Change the other occurances to make it appear on the category pages as well. In application_top.php, add: define('FILENAME_BEST_SELLERS', 'best_sellers.php'); Finally, in catalog/includes/languages/english/default.php, add: define('TABLE_HEADING_HOT_ITEMS', 'Hot Items'); That's it. It's pretty much a copy of the new_products.php file with a different SQL query. I have it set to display the max number set to the new products, but this can be easily changed if desired. Tony
mlulm Posted November 22, 2002 Posted November 22, 2002 Currently my category pages are not showing Whats New they are just a list of products that link to the product page. Is there something I need to do to change this so that it shows the best sellers? Thanks
Guest Posted November 22, 2002 Posted November 22, 2002 If you want to get your category pages to display bestsellers also, change the following line in defaulp.php from: <?php $new_products_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?> To: <?php include(DIR_WS_MODULES . FILENAME_BEST_SELLERS); ?> Tony
Guest Posted November 22, 2002 Posted November 22, 2002 Sorry, I misread your post. Let me clarify this. The bestsellers box will only display in the category page if there are subcategories. When you are in the deepest category, you will get a product llisting. If you want it to display the bestsellers in the deepest category, I'll have to make some other changes. Tony
mlulm Posted November 22, 2002 Posted November 22, 2002 I don't have sub-categories. What would be ideal would be to have the best sellers with the complete category list below it. If this is difficult don't worry about it. You have been a great help already. Thanks
Guest Posted November 22, 2002 Posted November 22, 2002 Ok...try this and let me know how it works out. First, in cstalog/includes/modules/best_sellers.php, change: $best_sellers_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_ordered from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_NEW_PRODUCTS); To: if ($cPath) { $best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_image, p.products_price, p.products_ordered from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $best_sellers_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_ordered from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_NEW_PRODUCTS); } Then in default.php, change: <tr> <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td> </tr> To: <tr> <td><br><?php include(DIR_WS_MODULES . FILENAME_BEST_SELLERS); ?></td> </tr> <tr> <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td> </tr> There may be an easier way to accomplish this, but it worked for me. Tony
mlulm Posted November 22, 2002 Posted November 22, 2002 You are amazing. It worked the first time. You should make this a contribution. The only problem is on the default page it says TABLE_HEADING_HOT_ITEMS which should be easy to fix. Also for others who might want to use this, due to my changing the requirments the last change ended up being from this. <tr> <td><?php include(DIR_WS_MODULES . FILENAME_BEST_SELLERS); ?></td> </tr> Thanks toady
Guest Posted November 22, 2002 Posted November 22, 2002 Glad it worked out for you! :) I made the changes to TABLE_HEADING and posted it as a contrib. I had thought about writing something like this earlier. Thanks for reminding me! (it got swept under the rug by some other ideas I had) Tony
mlulm Posted November 22, 2002 Posted November 22, 2002 I thought I could fix the TABLE_HEADING problem on the default page, but I can't seem to find it. Also where do you remove the rounded corner on the upper left.
mlulm Posted November 23, 2002 Posted November 23, 2002 I found my the TABLE_HEADING problem. I needed to add this to define('TABLE_HEADING_HOT_ITEMS', 'Hot Items'); to catalog/includes/languages/default.php insteat of catalog/includes/languages/english/default.php Still haven't figured our how to remove the rounded corner.
Guest Posted November 23, 2002 Posted November 23, 2002 You can change the round corner in catalog/includes/classes/boxes.php Near the bottom of the file, there is a function contentBoxHeading. Look in there for a reference to corner_left.gif. Change it to pixel_trans.gif and you should be set. :) Tony
blainehilton Posted November 26, 2002 Posted November 26, 2002 Is it possible to do this same type of mod, but instead of bestsellers change the default.php page so it shows a whole catagory? TIA --
dumb_question Posted November 30, 2002 Posted November 30, 2002 Is it possible to do this same type of mod, but instead of bestsellers change the default.php page so it shows a whole catagory?
mohan Posted August 4, 2006 Posted August 4, 2006 Hi, I am using latest oscommerce version 2.2-MS2. I am trying to do the same, that is to replace the "whats new" on the home page with "best sellers" Any advice most appreciated. Thanks. Mohan
Recommended Posts
Archived
This topic is now archived and is closed to further replies.