Jump to content

Randomize Latest Product


Guest

Recommended Posts

When i was running CC4 i had altered my includes/content/index.inc.php file, to Randomize my Latest Products on homepage, can anyone offer advice at which file I should be looking at in CC5 to achieve the same?

Link to comment
Share on other sites

  • 1 month later...

The code is in /classes/cubecart.class.php around line 72. The select function, if that's what you intend to modify, is in /classes/db/database.class.php around line 460.

Link to comment
Share on other sites

  • 2 months later...

The line where the latest products get selected from the database is cubecart.class.php line 74; it looks like this:

$latestProducts = $GLOBALS['db']->select('CubeCart_inventory', false,  array('status' => '1', 'featured' => '1'), array('date_added' => 'DESC', 'product_id' => 'DESC'), (int)$GLOBALS['config']->get('config', 'catalogue_latest_products_count'));




The variables getting passed to the select() function are $table, $columns, $where, $order, $maxRows. So what I'm assuming what you would need to do is change the order from DESC to RAND(). Replace "array('date_added' => 'DESC', 'product_id' => 'DESC')" with "'RAND()'" so the line looks like this:




$latestProducts = $GLOBALS['db']->select('CubeCart_inventory', false,  array('status' => '1', 'featured' => '1'), 'RAND()', (int)$GLOBALS['config']->get('config', 'catalogue_latest_products_count'));

That should do the trick.... in theory.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...