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

Manufacturer on Product List / Recommended

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 01-05-2013, 10:28 PM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default Re: Manufacturer on Product List / Recommended

Quote:
Originally Posted by cherie
I recommend doing a single query rather than a separate query for each product. For example (untested):

PHP Code:
$mids = array();
foreach (
$products as $p)
  
$mids[] = $p['manufacturerid'];
if (!empty(
$mids)) {
  
$manufacturers func_query_hash("SELECT manufacturerid,manufacturer FROM $sql_tbl[manufacturers] WHERE manufacturerid IN(".implode(',',$mids).")",'manufacturerid',FALSE,TRUE);
  foreach (
$products as $k=>$p)
    
$products[$k]['manufacturer'] = $manufacturers[$p['manufacturerid']];

I'd rather loop through products twice and do a single query than a single loop with multiple queries.

Hi Cherie
Thanks a lot your code works fine on all the pages for 4.5.4 i.e. on products.php, search.php & featured_products.php

Can you please explain me what is the advantage of your code ? I mean it will load the page fast or will use mysql more efficiently ?

Note: any body using this code just make sure that you do not keep any extra space on any line or you may get php error warning at admin/logs.php
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #12  
Old 01-06-2013, 09:06 AM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Manufacturer on Product List / Recommended

The thing that affects your site's performance the most is your database. You should always limit the number of database queries where possible.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
anandat (01-06-2013)
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 05:00 PM.

   

 
X-Cart forums © 2001-2020