Guest alvarito Posted November 30, 2012 Share Posted November 30, 2012 Hello, I did some search on this forums about changing the feature product in CC5, but I couldn't find any useful information regarding this subject. I found a couple but they didn't help or provide enough information. Does anyone know which file contains all the information for the feature product and therefore change it? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 30, 2012 Share Posted November 30, 2012 Hello alvarito, Most the data that pertains to a product is in the database. The GUI class is responsible for collecting that data and populating a collection of variables that are, in turn, used by the templating engine (Smarty) to render the HTML containing that data. Specifically, in the file gui.class.php, the function _displayRandomProduct() gets a random record from the database table (rejecting ineligible products), gets its image, asks for it to be translated, asks for the regular/sale prices to be managed and formatted, asks for a flag on whether one can purchase it if it is out of stock, asks for 'friendly' URL if the store is set to use those, invites any third-party modules if they have any contribution to make, then gives all that to Smarty in an array. Smarty uses the file box.featured.php (yes, featured and random are the same thing) to populate the {$place.holders} with the data collected earlier. That box as well as everything else is stitched together and sent to the browser. Quote Link to comment Share on other sites More sharing options...
Guest alvarito Posted November 30, 2012 Share Posted November 30, 2012 Hello alvarito, Most the data that pertains to a product is in the database. The GUI class is responsible for collecting that data and populating a collection of variables that are, in turn, used by the templating engine (Smarty) to render the HTML containing that data. Specifically, in the file gui.class.php, the function _displayRandomProduct() gets a random record from the database table (rejecting ineligible products), gets its image, asks for it to be translated, asks for the regular/sale prices to be managed and formatted, asks for a flag on whether one can purchase it if it is out of stock, asks for 'friendly' URL if the store is set to use those, invites any third-party modules if they have any contribution to make, then gives all that to Smarty in an array. Smarty uses the file box.featured.php (yes, featured and random are the same thing) to populate the {$place.holders} with the data collected earlier. That box as well as everything else is stitched together and sent to the browser. Thanks for the reply. So, if I wanted to set a static featured product do I have to modify "_displayRandomProduct()" ? Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 30, 2012 Share Posted November 30, 2012 Ok, by 'static', do you mean to say you want only the single admin chosen product to show in the Featured Product box? If so, then there is the easy way and the less than easy way. Edit the $where statement in the _displayRandomProduct() to say: $where = array('product_id' => ##); // replace ## with the product_id of the desired product. A somewhat more versatile approach is to add a field to the Add/Edit Product admin screen that flags that product as being the one product to show. Luckily, this free mod exists and can be adapted to suit: http://www.cubecartforums.org/index.php?showtopic=17088 Quote Link to comment Share on other sites More sharing options...
Guest alvarito Posted November 30, 2012 Share Posted November 30, 2012 Ok, by 'static', do you mean to say you want only the single admin chosen product to show in the Featured Product box? If so, then there is the easy way and the less than easy way. Edit the $where statement in the _displayRandomProduct() to say: $where = array('product_id' => ##); // replace ## with the product_id of the desired product. A somewhat more versatile approach is to add a field to the Add/Edit Product admin screen that flags that product as being the one product to show. Luckily, this free mod exists and can be adapted to suit: http://www.cubecartf...showtopic=17088 I tried the 2nd option and apparently there's a bug with hooks not showing up with Cubecart 5.1.4+, I guess i'll try the 1st option. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 1, 2012 Share Posted December 1, 2012 Please re-read the conversation regarding that mod. (Getting closer to a solid fix.) There isn't anything wrong with CC514 regarding the hooks that is pertinent to the mod. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 3, 2012 Share Posted December 3, 2012 I find this mod doesn't work (5.1.5) , either it still shows a random product (or wrong product) or just a no image icon Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 3, 2012 Share Posted December 3, 2012 Let's discuss the mod over at the other forum. Unless you mean the simple edit: $where = array('product_id' => ##); // replace ## with the product_id of the desired product. is what is not working. Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 4, 2012 Share Posted December 4, 2012 Let's discuss the mod over at the other forum. Unless you mean the simple edit: $where = array('product_id' => ##); // replace ## with the product_id of the desired product. is what is not working. No I meant the mod, perhaps I'm misunderstanding what it's supposed to do, I thought it would do what Alvarito is asking, ie just allow you to choose one featured product. But it seems more complex than that. Also I didn't understand the simple edit $where = array('product_id' => ##) I couldn't find that in gui.class.php Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 4, 2012 Share Posted December 4, 2012 That mod is more complex in that it is more versatile and better controlled. The simple edit to make in the _displayRandomProduct() function of the gui.class.php file is line 910. Quote Link to comment Share on other sites More sharing options...
Guest cybahous Posted December 13, 2012 Share Posted December 13, 2012 Hi Bsmither like Salvador, I couldn't find the simple code that you mention in your posts. I can see the section at line 910, but I can't see the $where = array('product_id' => ##) part. I have this: private function _displayRandomProduct($i=0) { $where = $GLOBALS['catalogue']->outOfStockWhere(array('status' => '1')); // SQL below used to replace RAND which is a monster on resources over 100 products $query = 'SELECT * FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` JOIN (SELECT CEIL(RAND() * (SELECT MAX(`product_id`) FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory`)) AS `product_id`) AS `r` USING (`product_id`) WHERE '.$where; $random_product = $GLOBALS['db']->misc($query); Should I change the 2 references to 'product_id' to the product code that I want to feature as my one featured product? Stew Quote Link to comment Share on other sites More sharing options...
salvador21 Posted December 15, 2012 Share Posted December 15, 2012 I have sort of solved the issue by just adding html to the skin/style/templates/main.php (This is for Kourouto with a RH sidebar, other styles would be different depending on the sidebar div but should be straightforward if you know a teeny bit of coding) I uploaded an image to it's own directory (e.g. /customimages/) After <div class="sidebar" id="sidebar_right"> I added the image location and link to product. Not ideal but it works: See: http://tamingthesaxophone.com/store/ Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 15, 2012 Share Posted December 15, 2012 Cybahous, In the file gui.class.php, the _displayRandomProduct function, since you are planning to have one and only one "designated" product be shown (as opposed to a random choice from x-number of products), we can simplify the query: private function _displayRandomProduct($i=0) { $where = array('product_id' => ##); // replace ## with the product_id of the desired product. $random_product = $GLOBALS['db']->select('CubeCart_inventory', false, $where ); if ($random_product) { Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted May 28, 2013 Share Posted May 28, 2013 New thread created for question about removing Featured Product section - http://forums.cubecart.com/topic/47380-remove-feature-product-replace-with-static/ 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.