Guest Reece Cropley Posted July 18, 2011 Share Posted July 18, 2011 Hello Guys I have been trying to find a out to get the featured product to be static. I have looked through the admin section and I cant seem to find anything to help me out. I have seen on the forums for previous cubecart versions that you can alter the randomProd.inc.php file and set the $whereClause variable so that it will only read out a specific product_id from the database. However the code for CC5 is different to CC3. //$whereClause = (isset($_GET['catId']) && is_numeric($_GET['catId'])) ? "AND I.cat_id=".$db->mySQLSafe($_GET['catId'])." AND I.cat_id > 0 AND C.hide != '1'" : "AND I.cat_id > 0"; $whereClause = "WHERE product_id = '3'"; $sql = sprintf("SELECT I.name, I.image, I.productId FROM %1\$sCubeCart_inventory AS I, %1\$sCubeCart_category AS C WHERE I.cat_id = C.cat_id AND I.disabled != '1' AND C.hide = '0' AND (C.cat_desc != '##HIDDEN##' OR C.cat_desc IS NULL) %2\$s ORDER BY RAND(%3\$d) LIMIT 1", $glob['dbprefix'], $whereClause, $seed); $randProd = $db->select($sql); Above is the altered $whereClause variable. It doesn't work. If anyone has already solved this or has any idea on how to I would like to know. Regards, Reece Cropley Quote Link to comment Share on other sites More sharing options...
goober999 Posted July 18, 2011 Share Posted July 18, 2011 Hello Guys I have been trying to find a out to get the featured product to be static. I have looked through the admin section and I cant seem to find anything to help me out. I have seen on the forums for previous cubecart versions that you can alter the randomProd.inc.php file and set the $whereClause variable so that it will only read out a specific product_id from the database. However the code for CC5 is different to CC3. //$whereClause = (isset($_GET['catId']) && is_numeric($_GET['catId'])) ? "AND I.cat_id=".$db->mySQLSafe($_GET['catId'])." AND I.cat_id > 0 AND C.hide != '1'" : "AND I.cat_id > 0"; $whereClause = "WHERE product_id = '3'"; $sql = sprintf("SELECT I.name, I.image, I.productId FROM %1\$sCubeCart_inventory AS I, %1\$sCubeCart_category AS C WHERE I.cat_id = C.cat_id AND I.disabled != '1' AND C.hide = '0' AND (C.cat_desc != '##HIDDEN##' OR C.cat_desc IS NULL) %2\$s ORDER BY RAND(%3\$d) LIMIT 1", $glob['dbprefix'], $whereClause, $seed); $randProd = $db->select($sql); Above is the altered $whereClause variable. It doesn't work. If anyone has already solved this or has any idea on how to I would like to know. Regards, Reece Cropley Find and edit file called "classes/gui.class.php". Inside that file find this line of code Thanks /Gooberif (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1'), 'RAND()', '1')) !== false) { The above is the select statement for the featured product. edit that line to fit your needs. It should look like this to force product_id 3 if (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1', 'product_id' => '3'), 'RAND()', '1')) !== false) { Quote Link to comment Share on other sites More sharing options...
Guest Reece Cropley Posted July 18, 2011 Share Posted July 18, 2011 Hello Guys I have been trying to find a out to get the featured product to be static. I have looked through the admin section and I cant seem to find anything to help me out. I have seen on the forums for previous cubecart versions that you can alter the randomProd.inc.php file and set the $whereClause variable so that it will only read out a specific product_id from the database. However the code for CC5 is different to CC3. //$whereClause = (isset($_GET['catId']) && is_numeric($_GET['catId'])) ? "AND I.cat_id=".$db->mySQLSafe($_GET['catId'])." AND I.cat_id > 0 AND C.hide != '1'" : "AND I.cat_id > 0"; $whereClause = "WHERE product_id = '3'"; $sql = sprintf("SELECT I.name, I.image, I.productId FROM %1\$sCubeCart_inventory AS I, %1\$sCubeCart_category AS C WHERE I.cat_id = C.cat_id AND I.disabled != '1' AND C.hide = '0' AND (C.cat_desc != '##HIDDEN##' OR C.cat_desc IS NULL) %2\$s ORDER BY RAND(%3\$d) LIMIT 1", $glob['dbprefix'], $whereClause, $seed); $randProd = $db->select($sql); Above is the altered $whereClause variable. It doesn't work. If anyone has already solved this or has any idea on how to I would like to know. Regards, Reece Cropley Find and edit file called "classes/gui.class.php". Inside that file find this line of code Thanks /Goober if (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1'), 'RAND()', '1')) !== false) { The above is the select statement for the featured product. edit that line to fit your needs. It should look like this to force product_id 3 if (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1', 'product_id' => '3'), 'RAND()', '1')) !== false) { Worked first time. Thank You Quote Link to comment Share on other sites More sharing options...
Guest Posted July 18, 2011 Share Posted July 18, 2011 Hello Guys I have been trying to find a out to get the featured product to be static. I have looked through the admin section and I cant seem to find anything to help me out. I have seen on the forums for previous cubecart versions that you can alter the randomProd.inc.php file and set the $whereClause variable so that it will only read out a specific product_id from the database. However the code for CC5 is different to CC3. //$whereClause = (isset($_GET['catId']) && is_numeric($_GET['catId'])) ? "AND I.cat_id=".$db->mySQLSafe($_GET['catId'])." AND I.cat_id > 0 AND C.hide != '1'" : "AND I.cat_id > 0"; $whereClause = "WHERE product_id = '3'"; $sql = sprintf("SELECT I.name, I.image, I.productId FROM %1\$sCubeCart_inventory AS I, %1\$sCubeCart_category AS C WHERE I.cat_id = C.cat_id AND I.disabled != '1' AND C.hide = '0' AND (C.cat_desc != '##HIDDEN##' OR C.cat_desc IS NULL) %2\$s ORDER BY RAND(%3\$d) LIMIT 1", $glob['dbprefix'], $whereClause, $seed); $randProd = $db->select($sql); Above is the altered $whereClause variable. It doesn't work. If anyone has already solved this or has any idea on how to I would like to know. Regards, Reece Cropley Find and edit file called "classes/gui.class.php". Inside that file find this line of code Thanks /Goober if (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1'), 'RAND()', '1')) !== false) { The above is the select statement for the featured product. edit that line to fit your needs. It should look like this to force product_id 3 if (($query = $GLOBALS['db']->select('CubeCart_inventory', false, array('status' => '1', 'product_id' => '3'), 'RAND()', '1')) !== false) { Worked first time. Thank You Does anybody know how to randomize Latest Products? Quote Link to comment Share on other sites More sharing options...
goober999 Posted July 18, 2011 Share Posted July 18, 2011 Does anybody know how to randomize Latest Products? you can't really randomize from a limited number of products. If you wanted to randomize from the entire catalog than that would be easy. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 19, 2011 Share Posted July 19, 2011 Does anybody know how to randomize Latest Products? you can't really randomize from a limited number of products. If you wanted to randomize from the entire catalog than that would be easy. Thats what I would like to happen, i.e. in the Latest products box, I would like it to pick at random any Products from my catalog but chance them at random any time the page is viewed or refreshed. Any ideas on how i can do this? I done it in CC4, but can't figure it out in CC5 Quote Link to comment Share on other sites More sharing options...
goober999 Posted July 20, 2011 Share Posted July 20, 2011 Does anybody know how to randomize Latest Products? you can't really randomize from a limited number of products. If you wanted to randomize from the entire catalog than that would be easy. Thats what I would like to happen, i.e. in the Latest products box, I would like it to pick at random any Products from my catalog but chance them at random any time the page is viewed or refreshed. Any ideas on how i can do this? I done it in CC4, but can't figure it out in CC5 try this Edit file: classes/cubecart.class.php Find this line $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')); change it to this line $latestProducts = $GLOBALS['db']->select('CubeCart_inventory', false, false, 'RAND()', (int)$GLOBALS['config']->get('config', 'catalogue_latest_products_count')); Enjoy /Goober Quote Link to comment Share on other sites More sharing options...
Guest Quiltessa Posted August 13, 2012 Share Posted August 13, 2012 Goober, It looks like the latest release changed the 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 would it be possible for you to look at it and give us the necessary change to keep the static featured product.. Thanks Quote Link to comment Share on other sites More sharing options...
Guest Viola Posted August 15, 2012 Share Posted August 15, 2012 you can't really randomize from a limited number of products. Um, well actually.... 1. Tick "Include in Latest Products" for all the products you want randomised (in this case that woud be the entire catalogue, but it can also just be a selection of products you want featured). 2. Set "Number of latest products to show" to however many products are set to be included in Latest Products. 3. In /skins/[yourskin]/templates/content.homepage.php find: {foreach from=$LATEST_PRODUCTS item=product} and add before: {capture}{$LATEST_PRODUCTS|@shuffle}{/capture} This will randomise the $LATEST_PRODUCTS array 4. To limit the number of products displayed, add the following after {foreach from=$LATEST_PRODUCTS item=product} {if $product@iteration > 3}{break}{/if} That will limit it to 3 products. Change the number to however many you want. Quote Link to comment Share on other sites More sharing options...
Guest Quiltessa Posted August 15, 2012 Share Posted August 15, 2012 Thank you for the reply and information.... I'll give that a try Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.