![]() |
Replacing "Featured Products" with "Recommend
I have (finally) managed to replace the "Featured Products" with "Recommended Products" on home.php - now 6 products are displayed at random instead of the static "Featured Products"
My next goal would be to make this now display the pricing information and the "Buy Now" button, in 2 rows of 3 products. I'm pretty sure that this would just be editing the recommends.tpl file.....any help would be appreciated! Heres what I did: in skin1/customer/home.tpl, add Code:
{include file="modules/Recommended_products/recommends.tpl"} Code:
{include file="customer/home_main.tpl"} In skin1/customer/main/welcome.tpl remove Code:
{include file="customer/main/featured.tpl" f_products=$f_products} and finally, in home.php add: Code:
if(!empty($active_modules["Recommended_Products"])) under Code:
if (empty($products)) This was done in 4.0.11 Hope this helps someone! Allan |
Works well, thanks :)
|
Re: Replacing "Featured Products" with "Recom
Quote:
Allan, Were you able to get this to work? Look forward to your reply, thanks! |
This is a great mod!
A couple notes from my own implementation: If you only want the above mod to appear on the homepage, use the following code in: skin1/customer/home.tpl Code:
{if $main eq "catalog" and $current_category.category eq ""} If you want to limit the number of random items that appear then you will want to use customer recommends.php. Personally, I created recommends_home.php and made the following modification: open recommends_home.php Code:
find: |
The mod doesn't works for me.
Did exactly what was descriped above. But getting this error: Code:
Warning: Smarty error: unable to read resource: "modules/Recommended_products/recommends.tpl" in /......./public_html/shop/Smarty-2.6.9/Smarty.class.php on line 1088 Recommends.tpl Code:
{* $Id: recommends.tpl,v 1.4.2.1 2005/10/31 14:10:44 max Exp $ *} |
I cant get this working either - same error message as above
|
Try emptying out the recommends.tpl file and just placing some text in there to see if the file is being found. If you get the same error make sure that your file is indeed at this location: modules/Recommended_products/recommends.tpl
Case sensitive! |
I just tried this and got the same error, it is a case-sensitive issue. In my store 3.5.10 the file is
modules/Recommended_Products/recommends.tpl Note the capital P of Recommended_Products - That it generating the error, hth |
Thanks Amy - that was the problem.
The following notes are for others who are looking at this hack- I now have recommended products randomly displaying in a 2 column 200 thumbnail format (thanks to Balinors Mod in Completed Mods). I've also added a hack to pull the price up 2 problems with doing all this -recommended products is displaying products that are hidden but available for sale - and the price is not displayed in the nicely formated including GST display that was on featured products. So the best way I feel is to request xcart to add a checkbox in future releases so that featured products can be dispayed randomy from the whole active product catalogue or a user nominated array. Hope this helps someone else |
X-Cart Gold 4.01
So I think I might be getting closer to what I'm looking for. So much discussion on this topic, but none of it exactly what I need. The situation: -Featured products set to random -Featured products module display called in the welcome.tpl Result: Featured products module boundaries and header show up, but it's empty 1. Why is is empty when I've told X-Cart to randomly select? 2. Once I get it past that point, how would I manually select items for display in featured items? Thanks. |
Quote:
could you post details of that hack, as I had tried one from this forum, but it doesn't show the price, just shows the list price! |
my version for 4.1.0rc4
create a file called random.php and put it in your stores root Code:
<? The query will only pick up live items that are in stock. Place: Code:
include "./random.php"; under Code:
if($active_modules["Bestsellers"]) in root/home.php create skin1/customer/main/randoms.tpl Code:
{* $Id: randoms.tpl,v 1.13 2002/05/20 06:55:20 lucky Exp $ *} <font class=big>From the Brew</font></font> edit skin1/customer/home.tpl or wherever you want to place the random products and use this code to call it: Code:
{include file="customer/main/randoms.tpl"} :lol: |
damnit, the query will sometimes show a product twice :x Anyone know how to modify the query so that it will only select an item once?
|
Quote:
Try this. Code:
SELECT $sql_tbl[products].*, (SELECT MIN($sql_tbl[pricing].price) FROM $sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0) AS price FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 ORDER BY RAND() LIMIT 6 If you use multiple languages or have categories limited to certain members you should look at the queries in recommends.php to sort out modifying the query further for those cases. If you care about taxed prices and thumbnail images you also need to add just before the smarty assign: Code:
if (is_array($randoms) && count($randoms) > 0) { |
hey gecko, thanks for your help/input
Im getting this error: Parse error: parse error, unexpected T_VARIABLE in /home/metapot/public_html/tcart/random.php on line 3 This how my random.php currently looks like Code:
<? |
Sorry, I just posted the SQL part of the statement. You need to assign it to $query like this:
Code:
$query = "SELECT $sql_tbl[products].*, (SELECT MIN($sql_tbl[pricing].price) FROM $sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0) AS price FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 ORDER BY RAND() LIMIT 6 "; |
hey gecko, thanks for your help.
I used your code and now random.php is: Code:
<? but now the cart shows this error: INVALID SQL: 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT MIN(xcart_pricing.price) FROM xcart_pricing WHERE xcart_ SQL QUERY FAILURE:SELECT xcart_products.*, (SELECT MIN(xcart_pricing.price) FROM xcart_pricing WHERE xcart_pricing.productid=xcart_products.productid AND xcart_pricing.quantity=1 AND xcart_pricing.variantid = 0) AS price FROM xcart_products,xcart_pricing WHERE forsale='Y' AND avail>0 ORDER BY RAND() LIMIT 6 |
Quote:
What version of MySQL are you using? The subquery used requires MySQL 4.1. Also, I found an error in the query that creates duplicate rows. Here's the fixed query also rewritten to work with earlier versions of MYSQL: Code:
$query = "SELECT $sql_tbl[products].*, MIN($sql_tbl[pricing].price) AS price FROM $sql_tbl[products],$sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0 AND forsale='Y' AND avail>0 GROUP BY $sql_tbl[products].productid ORDER BY RAND() LIMIT 6 "; |
thanks gecko, worked like a charm!
|
Hi guys,
I was trying out his mod. Had no luck, then immediately reverted back to my backed up files. Now I've lost my featured products on my home page!!! Even though I've gone back to my original site with featured products on my home page. I'm having some trouble here trying to rectify this. Someone please help. |
Quote:
The featured products are shown from the welcome.tpl file Check if this line is included into your customer/main/welcome.tpl file: {include file="customer/main/featured.tpl" f_products=$f_products} |
Thanks for replying.
Yes of course it is there. I just check. Since I reverted back to the original files as were before I attempted the mod, I can't understand why this is happening. Any other ideas?? Thanks. |
looks like a nice mod, i'll have to try it. Thanks for the work.
|
excellent mod. thank you for sharing your work. i do have one quick question.
any chance of getting this to only show recommended products when the featured products query returns no results? |
great mod ... works well in 4.1.2
only one thing that doesnt show is the price. instead it displays "Enter Your Price" ... After looking into this it's because the 'taxed_price' field isnt passed to the $randoms smarty variable .. Any ideas on how i can get this field passed ? Thanks & Regards Shafiq :sK |
Quote:
See my post earlier in this thread on how to do this. http://forum.x-cart.com/viewtopic.php?t=20135&postdays=0&postorder=asc&sta rt=13 |
Opps ... Missed that ..
Thanks for that :) Regards Shafiq :sK |
Ok ...
i've tried putting the addtional code in just before the smarty assign .. but now i get a blank page.. :? the code i have in random.php is as follows: // the database query $query = "SELECT $sql_tbl[products].*, (SELECT MIN($sql_tbl[pricing].price) FROM $sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0) AS price FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 ORDER BY RAND() LIMIT 6 "; // give the product array to smarty to make it available sitewide. $randoms = func_query($query); if (is_array($randoms) && count($randoms) > 0) { foreach ($randoms as $k=>$v) { $randoms[$k]["tmbn_url"] = func_get_thumbnail_url($v["productid"]); $randoms[$k]["taxes"] = func_get_product_taxes($randoms[$k], $login); } } $smarty->assign("randoms",$randoms); Can you help ? Regards Shafiq :sK |
I think i've sorted the issue..
I had to comment the following line: Quote:
The function 'func_get_thumbnail_url' doesnt exist in v4.1.2 (By looking at the /log/x-errors_php-xxxxxx.php file) The thumbmail still displays and the link to more product details work fine too. Regards Shafiq :sK |
This is a beauty in 4.1.2, thanks.
Can anyone get it to be category specific to the current cat. vs. random? The nice thing about this is you can use it for multiple instances. Like a "You Might Also Like..." and a sorta auto-generated cross-selling mod IF it was category specific. Anyone? Thanks! - Mike |
Quote:
I'm after this feature too ... Check this post out: http://forum.x-cart.com/viewtopic.php?t=16081#16081 I'm currently playing with it in v4.1.2 CartMods.com are selling a mod that does this: http://www.cartmods.com/product.php?productid=110 Sam @ CartMods has confirmed to me that it's compatible with 4.1.x too. Regards Shafiq :sK |
Re: Replacing "Featured Products" with "Recommend
Has anyone try this mod with a store that has several thousand of products? My concern is that it would have a negative performance impact going though long list with thousands of items trying to randomize it......Just a thought.
-Tuan |
Re: Replacing "Featured Products" with "Recommend
Awesome. I've have tried this mod as of X-cart release 4.1.3 and it work just as described. Now, if someone can point me to the right direction on how to revise the "Recommended Product" codes so that all thumbnails are referenced directly via filesystem instead of "image.php" file. Otherwise the frontpage would take forever to load all these randomized product images.
http://forum.x-cart.com/forumdisplay.php?f=18 Thanks guys. -Tuan |
Re: Replacing "Featured Products" with "Recommend
I tried this mod on 4.1.3, but when the following lines are added below to show pricing, I get a "Fatal error: Call to undefined function: func_get_product_taxes() in /home/path/to/random.php on line 8" error:
if (is_array($randoms) && count($randoms) > 0) { foreach ($randoms as $k=>$v) { $randoms[$k]["taxes"] = func_get_product_taxes($randoms[$k], $login); } } Anyone know why this is happening? |
Re: Replacing "Featured Products" with "Recommend
working in 4.1.7! great little mod.
|
Re: Replacing "Featured Products" with "Recommend
anyone have the answer to this...
i'm using this for 4 different random products on the main page... the problem is, duplicates. we've seen 2 of the same before, but i actually just saw 4 (yes, all four) random products, as the same item. if i could figure it out, i'd code it, but i can't. anyone have a solution to this?? thanks, j |
All times are GMT -8. The time now is 03:28 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.