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
  #1  
Old 11-12-2011, 11:52 PM
 
mhase mhase is offline
 

Newbie
  
Join Date: Nov 2011
Posts: 5
 

Question Manufacturer on Product List / Recommended

I searched through all of the previous topics mentioning this, but none of the solutions seem to have worked for me; I tried adding the following function to product.php:

Code:
//$thisManufactorer = $product_info["manufacturerid"]; //$manufacturer = func_query("SELECT manufacturer FROM manufacturers WHERE manufacturerid = $thisManufactorer"); //$smarty->assign("manufacturer", $manufacturer[0]);

(without commenting them out of course), which all seemed pretty straightforward, but didn't seem to work. Also tried (again in product.php):

Code:
$product_info['manufacturer'] = func_query("SELECT manufacturer FROM xcart_manufacturers WHERE manufacturerid='" . $product_info[manufacturerid] . "'");

which again, the logic behind it seems pretty straightforward to me, but didn't work. For reference, here is the code I'm using on the products_t.tpl:

Code:
<div class="brand">{$product.manufacturer}</div>

Webmaster mode even shows manufacturer as a variable under the product arrays, but I just can't seem to access it. Any help appreciated before I slam my head against the wall!
__________________
Version 4.4.4 Gold
Reply With Quote
  #2  
Old 11-13-2011, 12:16 AM
  XCart4Life's Avatar 
XCart4Life XCart4Life is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 62
 

Default Re: Manufacturer on Product List / Recommended

Check out the end of this thread. It looks like the same code but the smarty code they used to call the manufacturer was different. 7thdesire said this allowed him to see the manufacturer name on the products list.

Try changing (in your template products_t.tpl):

PHP Code:
<div class="brand">{$product.manufacturer}</div

To this:

PHP Code:
<div class="brand">{$manufacturer.manufacturer}</div

Edit: I forgot if you are using columns for your products list you want to edit products_t.tpl, if not edit product_list.tpl
__________________
X-Cart Pro v4.2.2 [Win]
X-Cart Pro v4.2.3 [Win]
X-Cart Pro v4.4.4 [Win]
Reply With Quote
  #3  
Old 11-13-2011, 01:23 AM
 
mhase mhase is offline
 

Newbie
  
Join Date: Nov 2011
Posts: 5
 

Default Re: Manufacturer on Product List / Recommended

Quote:
Originally Posted by XCart4Life
Check out the end of this thread. It looks like the same code but the smarty code they used to call the manufacturer was different. 7thdesire said this allowed him to see the manufacturer name on the products list.

Try changing (in your template products_t.tpl):

PHP Code:
<div class="brand">{$product.manufacturer}</div

To this:

PHP Code:
<div class="brand">{$manufacturer.manufacturer}</div

Edit: I forgot if you are using columns for your products list you want to edit products_t.tpl, if not edit product_list.tpl

Thanks for the idea - one of the codes I was testing in the OP was modified from 7thdesire's. I just plugged in the original again to see if it worked, and tried a few different arrangements for the variable on products_t and none of them appear to display anything:
{$manufacturer.manufacturer}
{$product.manufacturer}
{$manufacturer.manufacturer}{$product.manufacturer } - this one works on the individual product pages, at least!

The <div class="brand"></div>s are showing up though, so at least I'm fairly certain that I'm using the correct .tpl file
__________________
Version 4.4.4 Gold
Reply With Quote

The following user thanks mhase for this useful post:
Ana (01-13-2012)
  #4  
Old 11-13-2011, 04:28 PM
  XCart4Life's Avatar 
XCart4Life XCart4Life is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 62
 

Default Re: Manufacturer on Product List / Recommended

Ok I almost slammed my head into a wall too trying to figure this one out. Okay so here's the solution for X-Cart 4.4.4.

FORGET ABOUT PRODUCT.PHP!!! All the other posts are saying to add to that file and it doesn't do anything.

Edit:
/products.php
<---- That's products.... with a 'S' on the end

Find this at the bottom of the file:

PHP Code:
$smarty->assign('cat_products',      isset($products) ? $products : array()); 

Add this magical rare code above that line:
PHP Code:
if ($products)
    foreach (
$products as $k => $v)
$products[$k]['manufacturer'] = func_query_first_cell("select manufacturer from $sql_tbl[manufacturers] where manufacturerid = '$v[manufacturerid]'"); 

Now edit:
/skin/your_skin/customer/main/products_list.tpl (if you are using single column)
/skin/your_skin/customer/main/products_t.tpl (if you are using multi column)

Add this code where you want the manufacturer name to appear:
PHP Code:
{if $product.manufacturer ne ""}
    <
div class="brand">Brand: {$product.manufacturer}</div>
{/if} 

That makes it work on the regular category pages. But if you want it to appear on the search pages read on.


Edit:
/search.php


Find this line all the way at the bottom:

PHP Code:
// Assign the current location line
$smarty->assign('location'$location); 

Add this code above:

PHP Code:
if ($products)
    foreach (
$products as $k => $v)
$products[$k]['manufacturer'] = func_query_first_cell("select  manufacturer from $sql_tbl[manufacturers] where manufacturerid =  '$v[manufacturerid]'"); 

And that's all. This mod is free!
__________________
X-Cart Pro v4.2.2 [Win]
X-Cart Pro v4.2.3 [Win]
X-Cart Pro v4.4.4 [Win]
Reply With Quote

The following 4 users thank XCart4Life for this useful post:
am2003 (05-31-2012), anandat (01-04-2013), mhase (11-13-2011), Vivarant (04-13-2012)
  #5  
Old 11-13-2011, 06:15 PM
 
mhase mhase is offline
 

Newbie
  
Join Date: Nov 2011
Posts: 5
 

Default Re: Manufacturer on Product List / Recommended

It worked perfectly on both counts! Thank you so much.
__________________
Version 4.4.4 Gold
Reply With Quote
  #6  
Old 03-23-2012, 07:00 PM
 
Powertrain Powertrain is offline
 

Senior Member
  
Join Date: Mar 2011
Posts: 101
 

Default Re: Manufacturer on Product List / Recommended

Could this be turned into array and display manufacturers on category page?

display only manufacturers that exist in products belonging to category you are viewing

Thanks.
__________________
x-cart 4.4.2 Gold
Reply With Quote
  #7  
Old 01-03-2013, 06:36 AM
 
Gennifer Gennifer is offline
 

Newbie
  
Join Date: Dec 2012
Posts: 3
 

Default Re: Manufacturer on Product List / Recommended

XCart4Life--thanks so much for your solution. I was able to get this to work on the homepage of my site, but for some reason, it doesn't work on category or manufacturer product listing pages. Any idea why that might be?
__________________
4.5.3
Reply With Quote
  #8  
Old 01-04-2013, 07:33 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default Re: Manufacturer on Product List / Recommended

Thanks XCart4Life

I confirm that your code works for 4.5.4 gold+ also

Now, I just need some help to display for featured products on home page....do you have any idea ?
__________________
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
  #9  
Old 01-05-2013, 07:43 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Thumbs up Re: Manufacturer on Product List / Recommended

Ok I managed to show it for featured products also

Open featured_products.php

Find this at the bottom of the file:
PHP Code:
$smarty->assign('f_products'$products); 

Add this code above that line:

PHP Code:
if ($products)
    foreach (
$products as $k => $v)
$products[$k]['manufacturer'] = func_query_first_cell("select manufacturer from $sql_tbl[manufacturers] where manufacturerid = '$v[manufacturerid]'"); 

Done...Now it should display on featured products also on home page
__________________
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
  #10  
Old 01-05-2013, 02:55 PM
  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

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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following 2 users thank cherie for this useful post:
anandat (01-05-2013), DavyMac (05-18-2013)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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:23 AM.

   

 
X-Cart forums © 2001-2020