Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    40
    Plugin Contributions
    0

    Default Where does ZC pull the products in a category from database?

    Hi, I have a most vexing problem.

    I want to display the products in totally random order. Every time they refresh, I want it to show totally different products. I am selling t-shirts and bumper stickers, and I really don't want it showing the same few products at the top every time.

    I hate to bother the forum, but I have spent HOURS digging through the guts of ZC, grep'ping for every vaguely related term, etc.

    I thought it would be so easy - just find the SQL statement where it grabs the products to display, add an 'order by rand()' to the end of it, presto!

    But I just can't find this SQL statement ANYWHERE!! It is driving me bananas.

    I thought, for instance, it would be in /includes/classes/db/mysql/define_queries.php. But it doesn't seem to be. I also looked through all the core files, the function defines, the default template, the template I am using, etc. etc. I just don't know where else to look.

    Could someone please enlighten me as to where this logic might reside?

    Thank you!
    Sasha Shepherd

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Where does ZC pull the products in a category from database?

    Exactly *which* display component are you referring to? Are you talking about a "featured products" box? or a "specials" box? or the product-listing within each category? Are you saying you wish to completely ignore the customer's sort-preference selected in the pulldown? and ignore the default sort-order you've set within your admin?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Mar 2009
    Posts
    40
    Plugin Contributions
    0

    Default Re: Where does ZC pull the products in a category from database?

    Ah! I cracked it!!!!


    /includes/index_filters/default_filter.php

    I sure didn't think to look in that folder

    I just did a search in the file for everyhting that said '$sql_listing .='

    Commented all of it out.

    Then, wrote a single statement:

    $listing_sql .= " order by rand()";

    That solved it. Now all products display in random order :)

  4. #4
    Join Date
    Mar 2009
    Posts
    40
    Plugin Contributions
    0

    Default Re: Where does ZC pull the products in a category from database?

    Basically, in every category view, I wanted to totally ignore any sort preferences (my template disabled them for the customer anyway), and ONLY do random. It worked a charm :)

 

 

Similar Threads

  1. Additional Images pull from other database field?
    By micmed in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 3 Jan 2010, 03:03 AM
  2. where does the UPS mod get it's info from ?
    By snarkys in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 27 Aug 2007, 11:32 PM
  3. Replies: 0
    Last Post: 1 May 2007, 08:02 AM
  4. Where does the database go?
    By everyth5 in forum Installing on a Windows Server
    Replies: 1
    Last Post: 27 Aug 2006, 12:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg