mrnevets Posted June 11, 2010 Posted June 11, 2010 Hello I have found a contrib but it doesnt seem to help me out. (Im using a template :rolleyes: ) When you enter my site you see all the products I offer. There is also a "new products" button. When you click on "new products" you see all the products just like the "home" page. I want to have ALL products on "home" page and the new products on the "new products" page ...and I want the new products to disappear after some time. The contrib I found changed the layout of the template I am using and seemed to do what I wanted but backwards. IE It made the items on the "home" page disappear after a while and the "new products" stays forever :blink: Are there any other contribs out there that anyone knows of that maybe I missed? or does anyone know just the code changes so I dont distort my template? Thank you He who sits in jelly, has ass in jam.
germ Posted June 12, 2010 Posted June 12, 2010 You don't need to change anything but the DB query. I changed this: $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"; To this: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); $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 . "' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by p.products_date_added DESC, pd.products_name"; That shows the new products added in just the last 30 days. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
mrnevets Posted June 13, 2010 Author Posted June 13, 2010 Ok I will try this. Which file do I edit? (I would think new products.php?) :blink: He who sits in jelly, has ass in jam.
germ Posted June 13, 2010 Posted June 13, 2010 /catalog/products_new.php If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
mrnevets Posted June 17, 2010 Author Posted June 17, 2010 Thanks. Will let you know how it works! :D He who sits in jelly, has ass in jam.
Guest Posted June 20, 2010 Posted June 20, 2010 You don't need to change anything but the DB query. I changed this: $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"; To this: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); $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 . "' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by p.products_date_added DESC, pd.products_name"; That shows the new products added in just the last 30 days. I've been trying to sort this for ages, turned out although I'd copied and pasted your new code, I hadn't saved! (duh!) Anyway, now it's saved, and when I click on what's new, or latest products there are no products (as it should be). But...the what's new box is still there (showing not new products!) I know how to get rid of the box but I would want it there when there are new products, and don't know how to do that. Also, the home page is still showing the New Products For "Month", which I wouldn't mind, if there were any! Help? :) Chris
germ Posted June 20, 2010 Posted June 20, 2010 The fix for the "New Products for ..." on the home page goes something like this. All the changes are in /catalog/includes/modules/new_products.php BACKUP THE FILE BEFORE YOU ALTER IT!!! I tested all these code changes in a development area I have setup and it works with no errors. Change this line: new contentBoxHeading($info_box_contents); to: $save_box_contents = array(); $save_box_contents = $info_box_contents; Change this code: 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, pd.products_name, 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_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 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, pd.products_name, 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_DESCRIPTION . " pd, " . 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' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; To: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); 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,p.products_date_added, 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' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " 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,p.products_date_added, 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' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $count = 0; Change this code: $col ++; if ($col > 2) { $col = 0; $row ++; } to: $col ++; if ($col > 2) { $col = 0; $row ++; } $count++; Lastly change this code: new contentBox($info_box_contents); ?> <!-- new_products_eof //--> to: if ( $count ) { new contentBoxHeading($save_box_contents); new contentBox($info_box_contents); } ?> <!-- new_products_eof //--> Doing it like this the box won't even appear on the page if there are no new products added in the last 30 days. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Guest Posted June 20, 2010 Posted June 20, 2010 The fix for the "New Products for ..." on the home page goes something like this. All the changes are in /catalog/includes/modules/new_products.php BACKUP THE FILE BEFORE YOU ALTER IT!!! I tested all these code changes in a development area I have setup and it works with no errors. Change this line: new contentBoxHeading($info_box_contents); to: $save_box_contents = array(); $save_box_contents = $info_box_contents; Change this code: 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, pd.products_name, 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_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 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, pd.products_name, 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_DESCRIPTION . " pd, " . 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' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; To: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); 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,p.products_date_added, 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' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " 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,p.products_date_added, 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' and p.products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $count = 0; Change this code: $col ++; if ($col > 2) { $col = 0; $row ++; } to: $col ++; if ($col > 2) { $col = 0; $row ++; } $count++; Lastly change this code: new contentBox($info_box_contents); ?> <!-- new_products_eof //--> to: if ( $count ) { new contentBoxHeading($save_box_contents); new contentBox($info_box_contents); } ?> <!-- new_products_eof //--> Doing it like this the box won't even appear on the page if there are no new products added in the last 30 days. Hi - that took away the new products from the home page, but the box is still there in the side column :(
germ Posted June 20, 2010 Posted June 20, 2010 Hi - that took away the new products from the home page, but the box is still there in the side column :( Patience, Grasshopper.... :rolleyes: I'm getting to it. :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Guest Posted June 20, 2010 Posted June 20, 2010 Patience, Grasshopper.... :rolleyes: I'm getting to it. :) ok, lol, sorry, thought you'd done. :)
germ Posted June 20, 2010 Posted June 20, 2010 ok, lol, sorry, thought you'd done. :) No problemo.. :) I wanted to post the code changes separately so no one (you and anyone else reading this) would get confused about what change goes where. ;) This change is in /catalog/includes/boxes/whats_new.php AGAIN, BACKUP THE FILE BEFORE YOU ALTER IT!!! And as before I have tested this before posting and it works for me. Change this code: if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { To: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id,products_date_added, products_price from " . TABLE_PRODUCTS . " where products_status = '1' and products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { And, VOILA!!! Just like a potroast that's been in the crockpot all afternoon you're done. :D If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Guest Posted June 20, 2010 Posted June 20, 2010 No problemo.. :) I wanted to post the code changes separately so no one (you and anyone else reading this) would get confused about what change goes where. ;) This change is in /catalog/includes/boxes/whats_new.php AGAIN, BACKUP THE FILE BEFORE YOU ALTER IT!!! And as before I have tested this before posting and it works for me. Change this code: if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { To: $mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) ); if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id,products_date_added, products_price from " . TABLE_PRODUCTS . " where products_status = '1' and products_date_added >= '" . tep_date_raw($mdy) . "'" . " order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { And, VOILA!!! Just like a potroast that's been in the crockpot all afternoon you're done. :D Perfect. Thank you so much! :):) Chris
mrnevets Posted June 21, 2010 Author Posted June 21, 2010 GERM Now I did the first edit you said to make in the catalog/products_new.php I am wondering if I need to do what you posted after that... However, I have a "template" and the new_products.php file dont seem to be the same as I can find a couple of the lines you changed... :'( Or will the simple change I made get rid of the info after 30 days...? Im confused now :blink: He who sits in jelly, has ass in jam.
MrPhil Posted June 21, 2010 Posted June 21, 2010 Just out of curiosity, what is going to happen to your New Products page after every product has been around for at least 30 days? Do you regularly add new products so there will always be something there? It doesn't look too good for a store to have a "New Products" section with nothing in it -- it looks stagnant, with shelves full of old, dusty merchandise. What might be a better approach would be to sort products by "date added" and always show the N latest products, no matter how long ago they were added. Of course, frequent visitors might notice that you always have the same N products being promoted as "new". An alternative might be to check if you have fewer than some minimum number of genuinely new products, and pad out the rest of the list with a random selection of older products, calling it "New and Featured Products". Just some thoughts...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.