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

random.php/random product listing modification needed...

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-25-2007, 04:14 PM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default random.php/random product listing modification needed...

i'm running the random products on our main page, 4 across, and i need to remove one category (and all subs) from being displayed in that random display. so, say for example the main category is "kids clothes" or cat id 123.

i tried a few things in the template but guess i'm way off on the way to do this one, so i'm asking here now.

how can we either remove that from the query, or stop any of those products from being called into the loop of random preoducts in the template?

thanks.

here is random.php

Code:
<? // the database query $query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid ORDER BY RAND() LIMIT 4 "; // give the product array to smarty to make it available sitewide. $randoms = func_query($query); $smarty->assign("randoms",$randoms); ?>


here is the template...

Code:
{if $usertype eq "C" and $config.Appearance.products_per_row ne "" and $config.Appearance.products_per_row gt 0 and $config.Appearance.products_per_row lt 5 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")} {include file="customer/main/products_t2.tpl" products=$products} {else} {if $products} {section name=product loop=$products} {assign var="discount" value=0} <table width="90%" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td align="right" class="PListImgBox"> <div class="PListImgBox"> <a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_page}{if $featured eq 'Y'}&amp;featured{/if}">{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$config.Appearance.thumbnail_width product=$products[product].product tmbn_url=$products[product].tmbn_url}</a> </div> </td></tr> </table> <br /> <br /> <br /> {/section} {/if} {/if}
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
Reply With Quote
  #2  
Old 08-14-2007, 07:06 PM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default Re: random.php/random product listing modification needed...

bumping this since i can't get the syntax right on my own...


so, for this chunk in the PHP....


Code:
<? // the database query $query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid ORDER BY RAND() LIMIT 4 "; // give the product array to smarty to make it available sitewide. $randoms = func_query($query); $smarty->assign("randoms",$randoms); ?>


how can i exclude one cat, and all subcats.

for example. the main category id is 274

wouldn't it be close to....

AND $sql_tbl[categories].categoryid ne "274"

or something close that? what's another way to specify "not equal to" instead of the ne?

thanks,
j
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
Reply With Quote
  #3  
Old 08-18-2007, 12:47 AM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default Re: random.php/random product listing modification needed...

*crickets.

anyone have any ideas?
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
Reply With Quote
  #4  
Old 08-18-2007, 01:06 PM
 
inebriate inebriate is offline
 

eXpert
  
Join Date: May 2006
Posts: 301
 

Default Re: random.php/random product listing modification needed...

use NOT in the mysql query
__________________
x-cart pro 4.0.18
linux
www.fabric8d.com (currently undergoing construction)
Reply With Quote
  #5  
Old 08-18-2007, 09:05 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: random.php/random product listing modification needed...

On 4.1.8 the category information and the product information are seperated, and then connected with a join table called xcart_products_categories, so you have to add this table to the query and then tell the query not to show products in categoryid 274.

Try this:

Code:
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing],$sql_tbl[products_categories] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid AND $sql_tbl[products_categories].productid=$sql_tbl[products].productid AND $sql_tbl[products_categories].categoryid!='274' ORDER BY RAND() LIMIT 4;";
Reply With Quote
  #6  
Old 08-21-2007, 12:09 PM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default Re: random.php/random product listing modification needed...

hey jon, tried that, and i get nothing. the items from that category are showing up still.

we're still running 4.1.7 so i'm not sure if that is the problem or not.

any other ideas?

thanks,
j
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
Reply With Quote
  #7  
Old 09-27-2007, 03:12 PM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default Re: random.php/random product listing modification needed...

*bump.

okay, i think it isn't working with the main parent category. i'm trying all the active subcats...

so, would this be the right syntax to select mulitple subcats?


sql_tbl[products_categories].categoryid != '255' || '252' || '258'


thanks,
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
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 02:51 PM.

   

 
X-Cart forums © 2001-2020