Chryses Posted March 18, 2008 Posted March 18, 2008 Hi. Ther's any way, any modification to the query to show only the last X product that I've added? So I don't want to see the last 30 days products, but the last X products added... Anyone knows if ther's any contrib or the way to make it? Tnx a lo, Jo
arietis Posted March 19, 2008 Posted March 19, 2008 in the admin tool, under the heading "maximum values" there's a setting for "new products listing". it says "maximum number of new products to display in new products page" -- is this what you're looking for?
Chryses Posted March 19, 2008 Author Posted March 19, 2008 Unfortunately no :blush: This control the number of displayed products. I want to select the last X product added to the shop B) You know the way to do this? I think I need to modify the query, but I don't know how... Jo
burt Posted March 19, 2008 Posted March 19, 2008 order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); change to order by p.products_id desc limit 10"); Change 10 to whatever number you want to show.
Chryses Posted March 19, 2008 Author Posted March 19, 2008 Tnx for reply. It's similar that I want to do In this way you order the array to products_id, so limit the selection to the last X I want to make the array, select the last X products and order it in random or anyting. I think that I need a second query, the first to collect the last X product, and the second to order it in random or other..... What do you think? I'm still confused, what is the best way... :huh: Jo
arietis Posted March 19, 2008 Posted March 19, 2008 I think that I need a second query, the first to collect the last X product, and the second to order it in random or other..... sql likes things to be in order, so assigning a random order is a bit tricky. the easiest thing i can think of is, before the while() on line 32, read all the data into a single array and then randomize the order of that array. then you'd have to change the while() to iterate through that array. hope this helps.
Chryses Posted March 20, 2008 Author Posted March 20, 2008 Yep, you're right. I found Random New Products Shows Specials inc SubCats 1.0 With this I can randomize the query content, so I can collect the products and order it by date_added or products_id or other thing....and the result is that the products is always displayed in random So, solution found. Tnx
Jet200 Posted March 27, 2008 Posted March 27, 2008 I'm looking for a similar solution, while researching I'd like to limit the number of New Products but my code looks different than what is posted here. Currently the site just keeps adding to the New Products endlessly. I'd like to place some limits on this. Here's the code: <?php $products_new_array = array(); $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; $products_new_split = new splitPageResults($products_new_query_raw, 6); if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '2'))) { ?> THANKS
Recommended Posts
Archived
This topic is now archived and is closed to further replies.