Jump to content

Changing Feature Product. (Static perhaps?)


Guest alvarito

Recommended Posts

Guest alvarito

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest alvarito

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()" ?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest alvarito

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...
Guest cybahous

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

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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) {

Link to comment
Share on other sites

  • 5 months later...

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...