Random Manufacturers in Manufacturer menu box
Here's a quick mod to show random manufacturers in the Manufacturer menu box. Great for stores that have lots of manufacturers.
Open up modules/Manufacturers/customer_manufacturers.php Find this line: Code:
$manufacturers_menu = func_query("SELECT * FROM $sql_tbl[manufacturers] USE INDEX (avail) WHERE avail = 'Y' ORDER BY orderby LIMIT ".($config['Modules']['manufacturers_limit'])); Change it to this: Code:
$manufacturers_menu = func_query("SELECT * FROM $sql_tbl[manufacturers] USE INDEX (avail) WHERE avail = 'Y' ORDER BY RAND() LIMIT ".($config['Modules']['manufacturers_limit'])); # BCSE changed Carrie |
Wow, I just happened to need that for our new X-Mall. Thanks Carrie!
- Mike |
Glad I could help! ;) Such a simple mod but would be very useful to many stores. Should be an option in the x-cart admin I think.
Carrie |
An option, definitely! Manufactureres is a module, so a checkbox in module settings would suffice. I could see though that some stores still need to have control over their order, but it would be a nice way to get people to try different manufacturers, which often is a good result.
Thanks and we quite enjoy your X-mall feature... it adds a whole other dimension to using XC. - Mike |
Glad you like the X-mall. ;)
Carrie |
Re: Random Manufacturers in Manufacturer menu box
Hello Carrie,
I am getting following mysql error I guess due to version change. Can you please post the code for version 4.1.7 ? 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 '' at line 1 SQL QUERY FAILURE:SELECT * FROM xcart_manufacturers USE INDEX (avail) WHERE avail = 'Y' ORDER BY RAND() LIMIT |
Re: Random Manufacturers in Manufacturer menu box
I am using 4.1.8, and I have no matching code in my customer_manufactuers.php file.
Here is my file: ustomer_manufacturers.php,v 1.12.2.1 2007/03/22 13:54:54 svowl Exp $ # if ( !defined('XCART_START') ) { header("Location: ../"); die("Access denied"); } $manufacturers_menu = func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[manufacturers] USE INDEX (avail) WHERE avail = 'Y'"); if ($manufacturers_menu > 0) { if ($config["Manufacturers"]["manufacturers_limit"] > 0) $smarty->assign("show_other_manufacturers", $manufacturers_menu>$config["Manufacturers"]["manufacturers_limit"]); $manufacturers_menu = func_query("SELECT $sql_tbl[manufacturers].*, IF($sql_tbl[images_M].id IS NULL, '', 'Y') as is_image, $sql_tbl[images_M].image_path, IFNULL($sql_tbl[manufacturers_lng].manufacturer, $sql_tbl[manufacturers].manufacturer) as manufacturer, IFNULL($sql_tbl[manufacturers_lng].descr, $sql_tbl[manufacturers].descr) as descr FROM $sql_tbl[manufacturers] USE INDEX (avail) LEFT JOIN $sql_tbl[manufacturers_lng] ON $sql_tbl[manufacturers].manufacturerid = $sql_tbl[manufacturers_lng].manufacturerid AND $sql_tbl[manufacturers_lng].code = '$shop_language' LEFT JOIN $sql_tbl[images_M] ON $sql_tbl[manufacturers].manufacturerid = $sql_tbl[images_M].id WHERE $sql_tbl[manufacturers].avail = 'Y' ORDER BY $sql_tbl[manufacturers].orderby, $sql_tbl[manufacturers].manufacturer".(($config["Manufacturers"]["manufacturers_limit"] > 0) ? " LIMIT ".$config["Manufacturers"]["manufacturers_limit"] : "")); $smarty->assign("manufacturers_menu", $manufacturers_menu); } ?> |
Re: Random Manufacturers in Manufacturer menu box
Try this.
Find the: $manufacturers_menu = func_query( line in the modules/Manufacturers/customer_manufacturers.php file. Then find this in that line: ORDER BY orderby and change it to: ORDER BY RAND() Let me know if that doesn't work. Should be all you need to do though. Thanks! Carrie |
Re: Random Manufacturers in Manufacturer menu box
Sorry, no matches found.
The closest thing I could find is this: ORDER BY $sql_tbl[manufacturers].orderby, |
Re: Random Manufacturers in Manufacturer menu box
^ That's the same match, replace it.
|
All times are GMT -8. The time now is 01:04 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.