X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Random Manufacturers in Manufacturer menu box (https://forum.x-cart.com/showthread.php?t=13914)

BCSE 05-10-2005 12:14 PM

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

mffowler 05-16-2005 05:07 AM

Wow, I just happened to need that for our new X-Mall. Thanks Carrie!

- Mike

BCSE 05-16-2005 07:14 AM

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

mffowler 05-16-2005 11:42 AM

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

BCSE 05-16-2005 06:38 PM

Glad you like the X-mall. ;)

Carrie

anandat 06-18-2007 06:28 AM

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

g0t0pless 06-23-2007 10:56 PM

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);
}

?>

BCSE 06-30-2007 01:17 PM

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

g0t0pless 06-30-2007 08:06 PM

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,

Jon 06-30-2007 10:03 PM

Re: Random Manufacturers in Manufacturer menu box
 
^ That's the same match, replace it.

BCSE 07-01-2007 03:52 PM

Re: Random Manufacturers in Manufacturer menu box
 
Yes if you just find
ORDER BY <Something here>
you can replace that with
ORDER BY Rand()

Hope that helps!

Carrie

MBA 08-01-2007 12:21 PM

Re: Random Manufacturers in Manufacturer menu box
 
Quote:

Originally Posted by BCSE
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


Hi Carrie,

I assume one could list specific manufacturers in the manufacturer menu box by using the ORDER BY, but how would I call manufacturerid=21 and manufacturerid=832 specifically? Hope this isn't a huge deviation from the topic?

MBA 08-02-2007 06:55 PM

Re: Random Manufacturers in Manufacturer menu box
 
onto it here -

SELECT 'manufacturer_id' FROM 'xcart_manfacturers' WHERE 'manufacturer_id'
= 53 or WHERE 'manufacturer_id' = 60 or WHERE 'manufacturer_id' = 100

ORDER BY 'manufacturer_id'

The syntax isn't exactly right, but this should do it. Would someone help me with the syntax of the php as the is driving me nuts?

BCSE 08-02-2007 07:18 PM

Re: Random Manufacturers in Manufacturer menu box
 
Try this
SELECT 'manufacturer_id' FROM 'xcart_manfacturers' WHERE 'manufacturer_id'
= 53 or 'manufacturer_id' = 60 or 'manufacturer_id' = 100 ORDER BY 'manufacturer_id'

Basically take out the extra "where"'s

Carrie

MBA 08-08-2007 08:26 PM

Re: Random Manufacturers in Manufacturer menu box
 
Quote:

Originally Posted by BCSE
Try this
SELECT 'manufacturer_id' FROM 'xcart_manfacturers' WHERE 'manufacturer_id'
= 53 or 'manufacturer_id' = 60 or 'manufacturer_id' = 100 ORDER BY 'manufacturer_id'

Basically take out the extra "where"'s

Carrie


Bingo! Did it. Cheers.

BCSE 08-10-2007 01:27 PM

Re: Random Manufacturers in Manufacturer menu box
 
Great! :D

Carrie

RPMOffroad 10-28-2013 01:45 PM

Re: Random Manufacturers in Manufacturer menu box
 
Carrie you've done so much for me already ( the whole image checker module revamp you did last week) I hate to ask for any more. Is there a updated version of this for 4.4.5? The customer_manufacturers.php is a little different in this version.

BCSE 10-28-2013 07:17 PM

Re: Random Manufacturers in Manufacturer menu box
 
Hi! Boy you dug up an OLD thread. :D

For 4.4.5, look in the modules/Manufacturers/func.php and look for:
Code:

function func_get_manufacturers_list($avail_only = false, $limit = 0) {

Below that you will see:
Code:

. " ORDER BY orderby, manufacturer"
replace the orderby, manufacturer with Rand() like this:
Code:

. " ORDER BY Rand()"

I haven't tried it but it should work unless I missed something obvious.

Carrie

RPMOffroad 10-29-2013 05:14 AM

Re: Random Manufacturers in Manufacturer menu box
 
Its confirmed, you are a X-Cart Goddess!! Thanks again Carrie. :) Its amazing what you can do with this stuff!! Any testing on anything you want to do I am your guinea pig.:D/

BCSE 10-30-2013 08:03 AM

Re: Random Manufacturers in Manufacturer menu box
 
Quote:

Originally Posted by RPMOffroad
Its confirmed, you are a X-Cart Goddess!! Thanks again Carrie. :) Its amazing what you can do with this stuff!! Any testing on anything you want to do I am your guinea pig.:D/


Thanks! You're so kind! I'm glad it worked! :)

Carrie

tartaglia 11-07-2013 02:22 PM

Re: Random Manufacturers in Manufacturer menu box
 
Carrie,

Just made this change to my 4.5.4 store and it worked beautifully. Again thank you for this very useful post it is SUCH a good change!!!

BCSE 11-11-2013 01:56 PM

Re: Random Manufacturers in Manufacturer menu box
 
Great! I'm glad it was helpful!

Carrie

Learner 11-27-2013 06:57 AM

Re: Random Manufacturers in Manufacturer menu box
 
Quote:

Originally Posted by BCSE
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


In 4.6.1 How to display only category specific manufacturer in the category page? In category page only display that manufacturer name which is linked with that category.


All times are GMT -8. The time now is 10:17 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.