Guest dtmswebmaster Posted October 16, 2007 Share Posted October 16, 2007 I tried looking for the same code as in the CCv3 fix.. but didn't find it.. perhaps because this one is coded differently? Has anyone found the fix in the v4 edition? I'd be greatful if you could point me in the right direction with this. Thanks in advanced. Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted October 17, 2007 Share Posted October 17, 2007 OK... I think I've found the fix for it.... This is what I did: Open /yourstore/includes/content/index.inc.php and look around line 54 for: $cache = new cache('content.LatestProds'); $latestProducts = $cache->readCache(); if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY productId DESC LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } and change it to: $cache = new cache('content.LatestProds'); $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC LIMIT ".$config['noLatestProds']); Then save and upload to your store. This will randomize the Latest Products on the homepage. Quote Link to comment Share on other sites More sharing options...
Guest Mikes Web Dot Org Posted October 17, 2007 Share Posted October 17, 2007 OK... I think I've found the fix for it.... This is what I did: Open /yourstore/includes/content/index.inc.php and look around line 54 for: $cache = new cache('content.LatestProds'); $latestProducts = $cache->readCache(); if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY productId DESC LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } and change it to: $cache = new cache('content.LatestProds'); $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC LIMIT ".$config['noLatestProds']); Then save and upload to your store. This will randomize the Latest Products on the homepage. AWESOME!!! IT WORK FOR ME!!! THANKS A MILLION... But Can I do the same thing for the Sale items? MWDOLLC bestfilipinostore.com = CC4 (Secure) Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted October 17, 2007 Share Posted October 17, 2007 I'll check tonight.. and if I find anything.. I'll post it. Quote Link to comment Share on other sites More sharing options...
Guest topdotter Posted October 17, 2007 Share Posted October 17, 2007 Yes, using RAND() and a seed value will work. The only caveat in CC4 is that you have to have "Caching Enabled" in your Admin panel set to "No". If not it will still show the same products. The only problem with this is that it turns off caching for the entire store whcih will slow it down. A fix for this is to go to includes/content/index.inc.php and find the lines that say: if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND() LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } Replace them with //if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND() LIMIT ".$config['noLatestProds']); // $cache->writeCache($latestProducts); //} I realize that this isn't the most ideal solution since it's still making a call to the database every time. I'm going to work on code that adjusts the function to pull randomly from cached products. Quote Link to comment Share on other sites More sharing options...
Guest Mikes Web Dot Org Posted October 18, 2007 Share Posted October 18, 2007 Topdotter, I can't tr that code becuase I altered that for dtsm webmaster and random featured. Thanks though Someone else might use the tip! Oh and for the record... The other PHP didn't make me have to adjust the cache in gen set. MWDOLLC Bestfilipinostore.com CC4 (Secure) Yes, using RAND() and a seed value will work. The only caveat in CC4 is that you have to have "Caching Enabled" in your Admin panel set to "No". If not it will still show the same products. The only problem with this is that it turns off caching for the entire store whcih will slow it down. A fix for this is to go to includes/content/index.inc.php and find the lines that say: if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND() LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } Replace them with //if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND() LIMIT ".$config['noLatestProds']); // $cache->writeCache($latestProducts); //} I realize that this isn't the most ideal solution since it's still making a call to the server. I'm going to work on code that adjusts the function to pull randomly from cached products. Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted October 18, 2007 Share Posted October 18, 2007 The thing that I did was removed the parts in red from the code: ------------------Code-------------------------- $cache = new cache('content.LatestProds'); $latestProducts = $cache->readCache(); if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } ------------------End Code----------------------- I didn't have to make any changes in the admin panel for it to work either. Quote Link to comment Share on other sites More sharing options...
Guest Mikes Web Dot Org Posted October 18, 2007 Share Posted October 18, 2007 :( Confused.... All i know is it worked. thanks again. The thing that I did was removed the parts in red from the code: ------------------Code-------------------------- $cache = new cache('content.LatestProds'); $latestProducts = $cache->readCache(); if (!$cache->cacheStatus) { $latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC LIMIT ".$config['noLatestProds']); $cache->writeCache($latestProducts); } ------------------End Code----------------------- I didn't have to make any changes in the admin panel for it to work either. Quote Link to comment Share on other sites More sharing options...
Guest Brivtech Posted October 18, 2007 Share Posted October 18, 2007 Does this run the risk of pulling up the same item twice? Quote Link to comment Share on other sites More sharing options...
Guest topdotter Posted October 18, 2007 Share Posted October 18, 2007 Does this run the risk of pulling up the same item twice? No. The SQL query gets each product only once. Ideally, what I'd like to do is run a SQL query pull ALL the products that are supposed to be shown in the latest products, cache them all, and have the application then pull the correct number from cache randomly. Best of both worlds. Quote Link to comment Share on other sites More sharing options...
Guest Brivtech Posted October 18, 2007 Share Posted October 18, 2007 This really is a fantastic modification that's also simple. Good work! Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted October 20, 2007 Share Posted October 20, 2007 Ok.. I was able to randomize the "Sale" Items box that is displayed on the homepage if you have items on a "Sale" price. The same trick can be applied here that was used for the "Latest Products". Open /YourStore/includes/boxes/saleitems.inc.php Find this line (around line 33): ## query database $cache = new cache('boxes.saleItems'); $saleItems = $cache->readCache(); if (!$cache->cacheStatus) { $saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$glob['dbprefix']."CubeCart_inventory WHERE price > sale_price AND sale_price > 0 AND cat_id > 0 ORDER BY saving DESC",$config['noSaleBoxItems']); $cache->writeCache($saleItems); } And change it to show like this: ## query database $cache = new cache('boxes.saleItems'); $saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$glob['dbprefix']."CubeCart_inventory WHERE price > sale_price AND sale_price > 0 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC",$config['noSaleBoxItems']); Save and upload. That's it! Hope this works for ya. P.S.: If anyone can get this to work with cache enabled, I'd be glad to hear your ideas. Quote Link to comment Share on other sites More sharing options...
Guest Mikes Web Dot Org Posted October 20, 2007 Share Posted October 20, 2007 DTMS, You are the "MASTER"! It worked like a charm... Thanks so much! Different subject but any progess on the "more than one word" search box problem? Thanks again in advance! Maybe you should be on the develpoment team for CC. Many Thanks MWDOLLC BestFilipinoStore Ok.. I was able to randomize the "Sale" Items box that is displayed on the homepage if you have items on a "Sale" price. The same trick can be applied here that was used for the "Latest Products". Open /YourStore/includes/boxes/saleitems.inc.php Find this line (around line 33): ## query database $cache = new cache('boxes.saleItems'); $saleItems = $cache->readCache(); if (!$cache->cacheStatus) { $saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$glob['dbprefix']."CubeCart_inventory WHERE price > sale_price AND sale_price > 0 AND cat_id > 0 ORDER BY saving DESC",$config['noSaleBoxItems']); $cache->writeCache($saleItems); } And change it to show like this: ## query database $cache = new cache('boxes.saleItems'); $saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$glob['dbprefix']."CubeCart_inventory WHERE price > sale_price AND sale_price > 0 AND cat_id > 0 ORDER BY RAND(".$seed.") DESC",$config['noSaleBoxItems']); Save and upload. That's it! Hope this works for ya. P.S.: If anyone can get this to work with cache enabled, I'd be glad to hear your ideas. Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted October 21, 2007 Share Posted October 21, 2007 Thanks Mikes... never really thought about it though.. I'm good with making changes to current code .. not so good at developing it though. If I happen to get better with PHP and the dev team could use a hand.. I may see about joining the wagon, as it were :D Quote Link to comment Share on other sites More sharing options...
Guest Mikes Web Dot Org Posted November 2, 2008 Share Posted November 2, 2008 :yeahhh: Just want to thank all the CC Crew and Forums and Help I have received. I have closed the Best Filipino Store and opened VG Consoles. I applied the same code below to the newer updated version of CC 4 and it still works like a chram. Just FYI. MWDO LLC AKA VG Consoles L8R :D Quote Link to comment Share on other sites More sharing options...
generaldogsbody Posted May 22, 2010 Share Posted May 22, 2010 Thanks that works great 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.