Guest Posted November 17, 2009 Posted November 17, 2009 When ever i add a product the front page show the same items all the time I purchased a template and need the products to be randomised. Can anyone please post the lines i need to change the products from being fixed to being random Thank you
Guest Posted November 17, 2009 Posted November 17, 2009 Hard to say with a template. If you have a file in catalog/includes/modules/new_products.php post the code.
Guest Posted November 17, 2009 Posted November 17, 2009 As requested new_products.php Thank you <!-- new_products //--> <?php //$info_box_contents = array(); //$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'))); //new contentBoxHeading($info_box_contents); if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $new_products['products_name'] = tep_get_products_name($new_products['products_id']); $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); $product = tep_db_fetch_array($product_query); $new_products['products_description'] = $product['products_description']; if(($row%2)<>0) { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'colspan="5" valign="top" height="1" ', 'text' => tep_image(DIR_WS_IMAGES . 'spacer.gif', '', '10','','style="margin-right:0px "') ); $row++; } $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" valign="top"', 'text' => ' <table width="260" border="0" cellspacing="0" cellpadding="0" class="border"> <tr> <td ><span class="NameProd">' . $new_products['products_name'] . '</span> </td> </tr> <tr> <td> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> </td> <td> <img src="images/spacer.gif" alt="" width="11" border="0" height="1"><br> </td> <td> <span class="Date">' . preg_replace('/\s\S*$/i', '', substr($new_products['products_description'], 0, 120)) . '...</span> <img src="images/spacer.gif" alt="" width="1" border="0" height="9"> <span class="iinfo">' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</span><br> </td> </tr> </table> <img src="images/spacer.gif" alt="" width="1" border="0" height="13"><br> </td> </tr> <tr> <td class="iinfo2" align="left"><a class="iinfo2" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">details</a><img src="images/spacer.gif" alt="" width="130" border="0" height="1"><a class="iinfo2" href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">add to cart</a> </td> </tr> </table> '); $col ++; if($col == 1) { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'valign="top" ', 'text' => '' ); $col ++; } if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); ?> <!-- new_products_eof //-->
Guest Posted November 17, 2009 Posted November 17, 2009 In the 2 query strings $new_products_query find towards the end order by p.products_date_added desc Change to order by rand()
Guest Posted November 17, 2009 Posted November 17, 2009 1 more question the no of new products is set to 4 i like to increase to 6 where do i find how to increase the products ? Thank you
burt Posted November 17, 2009 Posted November 17, 2009 Explore your admin area - particularly the "min" and "max" stuff in configuration
forummaker Posted April 24, 2010 Posted April 24, 2010 I've searched for an answer to this but just can't find it... Hope it's ok to post here. How do I show a random review on the right side of the page? It currently shows the most recent review that was written. I would rather have a random review display whenever the page is refreshed. Anyone know how to do this? I tried working with the code as suggested in this topic into the boxes/review.php file.. but no luck. Just not good enough with coding. Thanks for any help with this. That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
NodsDorf Posted April 25, 2010 Posted April 25, 2010 I've searched for an answer to this but just can't find it... Hope it's ok to post here. How do I show a random review on the right side of the page? It currently shows the most recent review that was written. I would rather have a random review display whenever the page is refreshed. Anyone know how to do this? I tried working with the code as suggested in this topic into the boxes/review.php file.. but no luck. Just not good enough with coding. Thanks for any help with this. To increase your products in the box go to admin > configuration > maximum values > new products module
forummaker Posted April 25, 2010 Posted April 25, 2010 Thanks for a response.. but not exactly what I was looking for... but I did figure it out. Here's what I did. products_reviews.php file Locate: $languages_id . "' order by r.reviews_id desc"; Change to: $languages_id . "' order by rand()"; Seems to be working. Any feedback on this code change? Thanks. That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.