Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Bestsellers with short descriptions...

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-21-2008, 11:04 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Bestsellers with short descriptions...

I am trying to modify my bestsellers to include the short description, I have added the $bestseller.descr but it does not show any descriptions.

My question:
Where is the database query for the bestsellers? I want to add descr to the list so that it will display them when prompted. I have looked at bestsellers.php but dont see it there. Here is the code for the tpl as it stands right now:

Code:
{capture name=bestsellers} <table cellpadding="0" cellspacing="2"> {foreach from=$bestsellers item=bestseller} <tr> {if $config.Bestsellers.bestsellers_thumbnails eq "Y"} <td width="30"> <a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}"> {include file="product_thumbnailbs.tpl" productid=$bestseller.productid product=$bestseller.product tmbn_url=$bestseller.tmbn_url}</a> </td> {/if} <td> <b><a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}">{$bestseller.product}</a></b><br /> {$bestseller.descr}<br /> {$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.taxed_price}<br /> </td> </tr> {/foreach} </table> {/capture} {include file="dialog.tpl" title=$lng.lbl_bestsellers content=$smarty.capture.bestsellers extra='width="100%"'} {/if}

Thanks a bunch for the help guys!
Herb
webmaster@bunnyburybaby.com
__________________
X-Cart Version 4.1.8
Reply With Quote
  #2  
Old 02-22-2008, 04:19 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Bestsellers with short descriptions...

This is your new /skin1/modules/Bestsellers/menu_bestseller.tpl
I've correct some errors like
'thumbnailbs' -> 'thumbnail'
one excess {/if}

Code:
{capture name=bestsellers} <table cellpadding="0" cellspacing="2"> {foreach from=$bestsellers item=bestseller} <tr> {if $config.Bestsellers.bestsellers_thumbnails eq "Y"} <td width="30"> <a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}"> {include file="product_thumbnail.tpl" productid=$bestseller.productid product=$bestseller.product tmbn_url=$bestseller.tmbn_url}</a> </td> {/if} <td> <b><a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}">{$bestseller.product}</a></b><br /> {$bestseller.descr}<br /> {$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.taxed_price}<br /> </td> </tr> {/foreach} </table> {/capture} {include file="dialog.tpl" title=$lng.lbl_bestsellers content=$smarty.capture.bestsellers extra='width="100%"'}

and this is your LAST 20 ROWS of your new /modules/Bestsellers/bestsellers.php. You should find row with 'if ($threshold)' and replace it to end of file with

Code:
if ($threshold) $threshold -= 1; $search_query['where'][] = " $sql_tbl[products_categories].categoryid IN ('".implode("','", $cat_ids)."')"; unset($result); } # # Search the bestsellers # $search_query['where'][] = "$sql_tbl[products].views_stats > '0' AND $sql_tbl[products].sales_stats >= '".$threshold."'"; $search_query['fields'][] = "xcart_products.descr"; $bestsellers = func_search_products($search_query, @$user_account["membershipid"], "$sql_tbl[products].sales_stats DESC, $sql_tbl[products].views_stats DESC", $config["Bestsellers"]["number_of_bestsellers"] ); $smarty->assign("bestsellers", $bestsellers); ?>

Enjoy!
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote
  #3  
Old 02-22-2008, 08:20 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Bestsellers with short descriptions...

Holub,

I made the changes you suggested but the module still does not show me the descriptions. Could I be doing something wrong?

Here is the code for the tpl I am working with. I should have named the template in my last post, I apologize for that. This only needs to work with the bestsellers.tpl, I do not use the menu_bestseller.tpl

bestsellers.tpl

Code:
{* $Id: bestsellers.tpl,v 1.8.2.1 2006/11/16 13:12:29 max Exp $ *} {if $bestsellers} <font color="#6C8197" style="font: bold 14px Verdana, Arial, Helvetica, Sans-Serif;"><b>More Best Selling Products:</b></font> <br clear="left"><img src="http://www.bunnyburybaby.com/images/line.jpg" width=619 height=1 alt="Featured Baby Gift Basket Line" align="left"><br clear="left"> {capture name=bestsellers} <table cellpadding="0" cellspacing="2"> {foreach from=$bestsellers item=bestseller} <tr> {if $config.Bestsellers.bestsellers_thumbnails eq "Y"} <td width="30"> <a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}"> {include file="product_thumbnailbs.tpl" productid=$bestseller.productid image_x=25 product=$bestseller.product tmbn_url=$bestseller.tmbn_url}</a> </td> {/if} <td> <b><a href="product.php?productid={$bestseller.productid}&amp;cat={$cat}">{$bestseller.product}</a></b><br /> {$bestseller.descr} <br /> {$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.taxed_price}<br /> </td> </tr> {/foreach} </table> {/capture} {include file="dialog.tpl" title=$lng.lbl_bestsellers content=$smarty.capture.bestsellers extra='width="100%"'} {/if}

Here is the code for my bestsellers.php after the change you suggested:

Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2007 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2007 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: bestsellers.php,v 1.31.2.3 2007/03/28 08:06:39 max Exp $ # # Bestsellers # if (!defined('XCART_SESSION_START')) { header("Location: ../../"); die("Access denied"); } x_load('product'); if (!is_numeric($config["Bestsellers"]["number_of_bestsellers"]) || $config["Bestsellers"]["number_of_bestsellers"] < 0) $config["Bestsellers"]["number_of_bestsellers"] = 0; # # Get products data for current category and store it into $products array # $avail_condition = ""; if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") $avail_condition = " AND $sql_tbl[products].avail>0 "; $cat = intval($cat); $search_query = ''; $threshold = 0; if ($cat) { $category_data = func_query_first("SELECT categoryid_path, threshold_bestsellers FROM $sql_tbl[categories] USE INDEX (PRIMARY) WHERE categoryid = '$cat'"); $result = func_query_hash("SELECT categoryid, threshold_bestsellers FROM $sql_tbl[categories] USE INDEX (pa) WHERE categoryid_path LIKE '$category_data[categoryid_path]/%' AND avail = 'Y'", "categoryid", false, true); $threshold = intval($category_data["threshold_bestsellers"]); $cat_ids = array(); if (is_array($result) && !empty($result)) { $cat_ids = array_keys($result); foreach ($result as $threshold_bestsellers) { if ($threshold_bestsellers > 0 && $threshold > $threshold_bestsellers) $threshold = intval($threshold_bestsellers); } } else { $cat_ids[] = $cat; } if ($threshold) $threshold -= 1; $search_query['where'][] = " $sql_tbl[products_categories].categoryid IN ('".implode("','", $cat_ids)."')"; unset($result); } # # Search the bestsellers # $search_query['where'][] = "$sql_tbl[products].views_stats > '0' AND $sql_tbl[products].sales_stats >= '".$threshold."'"; $search_query['fields'][] = "xcart_products.descr"; $bestsellers = func_search_products($search_query, @$user_account["membershipid"], "$sql_tbl[products].sales_stats DESC, $sql_tbl[products].views_stats DESC", $config["Bestsellers"]["number_of_bestsellers"] ); $smarty->assign("bestsellers", $bestsellers); ?>

The descriptions are still not showing up. Not sure why. I have a short description on the product pages.

Here is my /product_thumbnailbs.tpl for those interested:

Code:
<img src="phpThumb.php?src={$tmbn_url|replace:' ':'%20'|replace:'http://www.bunnyburybaby.net/':''|replace:'http://www.bunnyburybaby.com/':''|replace:'images/products':'images/Products'}&w=75" alt="{$images[image].alt}" style="BORDER-RIGHT: #b7b7b7 1px solid; BORDER-TOP: #b7b7b7 1px solid; BORDER-LEFT: #b7b7b7 1px solid; BORDER-BOTTOM: #b7b7b7 1px solid" alt="$bestseller.product">

This is a 4 year old site with over 1000 products. The folks working on it before me liked to use spaces, capitals etc in the image names, urls and other places you should not. I had to put some replace commands in to correct past errors.

I will moving the excess html to a css once I have the mod working.

Any help you can give is much appreciated.

Herb
__________________
X-Cart Version 4.1.8
Reply With Quote
  #4  
Old 02-25-2008, 10:30 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Bestsellers with short descriptions...

Any other ideas? All are welcome!
__________________
X-Cart Version 4.1.8
Reply With Quote
  #5  
Old 02-27-2008, 08:05 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Bestsellers with short descriptions...

Do you have any php/mysql errors in logs? I can't find right decision without additional info. Can you provide me website address where you try to use these modifications?
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote
  #6  
Old 02-27-2008, 10:01 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Bestsellers with short descriptions...

No errors in the logs, you can see it near the bottom of this page: http://dev.bunnyburybaby.com/home.php The first "More Best Selling Products: " section is hard coded right now, the one below it is the best sellers module as it stands right now. You can see the second set of products is missing the short description.
__________________
X-Cart Version 4.1.8
Reply With Quote
  #7  
Old 02-28-2008, 01:07 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Bestsellers with short descriptions...

Hm... It's very strange. I've created new files (bestsellers.php and bestsellers.tpl and inserted code I've suggested - and it's work. There is one rationale I can suppose: in version 4.1.8 this method does not work (I've tested on 4.1.9). I'll try to test it on 4.1.8.
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote
  #8  
Old 02-28-2008, 01:11 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Bestsellers with short descriptions...

Yes, all OK. I'ts my fault, the function func_search_products was changed in 4.1.9.

There is less quality decision than previous. Please rollback changes and choose standart bestsellers.php file (without modifications). Then you should insert this code into bestsellers.php

Code:
foreach ($bestsellers as $k => $v) { $bestsellers[$k]['descr'] = func_query_first_cell("select descr from $sql_tbl[products] where productid='$v[productid]'"); }

before lines (almost the end of file)

Code:
$smarty->assign("bestsellers", $bestsellers); ?>

I've tested this on 4.1.8 and found this work properly.

Feel free to ask any questions.
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote
  #9  
Old 07-03-2008, 07:17 PM
 
Thedae2k Thedae2k is offline
 

eXpert
  
Join Date: Jan 2004
Posts: 288
 

Default Re: Bestsellers with short descriptions...

All first early worked great in my 4.1.9 project...funny how your always at the end of fixing what I'm looking for Anthony. Thanks for always contributing.
__________________
X-Cart Pro 4.1.9
PHP5.2.5
MySQL 5.0.54
IIS/Apache/NGINX Webservers
Reply With Quote
  #10  
Old 07-07-2008, 01:17 PM
 
Thedae2k Thedae2k is offline
 

eXpert
  
Join Date: Jan 2004
Posts: 288
 

Default Re: Bestsellers with short descriptions...

How would I get the manufacturers name to display before the product name in the bestsellers.tpl?
__________________
X-Cart Pro 4.1.9
PHP5.2.5
MySQL 5.0.54
IIS/Apache/NGINX Webservers
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:50 AM.

   

 
X-Cart forums © 2001-2020