X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   get manufacture in products.php (https://forum.x-cart.com/showthread.php?t=10007)

BCSE 07-04-2005 07:07 AM

Someone came to me unable to get this code to work on their site and I wasn't able to fix it either so I created another way to do this.

To show the manufacturer on a per product basis on products.php you can also do this instead:

In products.php before:
Code:

$smarty->assign("products",$products);

Insert:
Code:

if($products)
{
        foreach($products as $key=> $product)
                $products[$key]["manufacturer"]= func_query_first_cell("select manufacturer from $sql_tbl[manufacturers] where manufacturerid=".$product["manufacturerid"]);
}


In skin1/customer/main/products_t.tpl or skin1/customer/main/products.tpl insert the following where you want the manufacturer to show up
Code:

{$products[product].manufacturer}

Hope that helps those who are stuck! A bit less code and less files to edit.

Carrie

fearnothing 07-10-2005 11:00 AM

Hi Carrie

Just followed this thread through, and the main suggestions definitely don't work for me either (incorrect manufacturers, links to wrong manufacturers etc.) but your mod does work ... but only in certain situations:

products.tpl works fine when called from home.php?cat=x but not when called from search.php?mode=search

Can't get the code to work at all in products_t.tpl

Any suggestions?

Also, what would be the code to turn the Manufacturer name into an url? The code posted earlier in the thread is obviously relating to the original functions.

On a general point, anyone know why Carrie's variation is needed for some projects and not others?

Many thanks, FN

BCSE 07-10-2005 07:26 PM

FN,

I'm not surprised it doesn't work for search.php You would need to add similar code to search.php If I get a chance, I will look into it and post the code here.

Also, this does work for product_t.tpl as that's what I used it on when writing the code, however, if you're talking about in the featured products section, then php code may need to be added to featured_products.php file I'd have to look at the code flow to be sure, but I believe that is the case.

Hope this helps some and if I get a chance I'll look into your questions more and post findings.

Carrie

fearnothing 07-11-2005 09:53 AM

Thanks for that Carrie - This facility on Search results would make a big difference to my project.

Regarding product_t.tpl my only dealing with this so far is in Featured Products - I don't know what other features use this template??

I dug around in the forum after you said this, and this thread has provided the code for Manufacturer to appear in Featured Products:

http://forum.x-cart.com/viewtopic.php?t=19684

I'll take a look now and see if I can use it in Search Results

This subject seems to be turning up in lots of guises in different parts of the forum - It might be useful if someone with more knowledge than I have rounds up all of this useful information at some stage??

fearnothing 07-11-2005 10:08 AM

It looks like a combination of code snippets from Carrie's solution, the main solution in this thread and the one in the thread I referred to in my last post has done the trick.

It seems as though the php code in http://forum.x-cart.com/viewtopic.php?t=19684 has generated the correct results for the template changes suggested by Carrie.

I now have Manufacturers appearing in products.tpl and product_t.tpl whether viewing by categories or by seach results, and also in Featured Products. The code to have Manufacturers appear in product.tpl as suggested in this post also works a treat.

Good news all round - sincere thanks to all the forumistas who have contributed to this one!!

FN

BCSE 07-12-2005 06:56 AM

Glad you got it figured out.

products_t.tpl can be used on the normal products.php pages if you have in the admin set for products to be showin in multi column format.

Carrie

fearnothing 07-12-2005 12:14 PM

A-ha ... so that's where that template shows up. Useful information and something to bear in mind when I'm tinkering with it.

Much appreciated! FN.

HWT 07-20-2005 12:55 PM

This also works like a charm for the search (thanks everyone who's posted) - this is an extension of Carrie's solution

in include/search.php

just before:

Code:

$smarty->assign("products",$products);

include:

Code:

if($products)
{
  foreach($products as $key=> $product)
      $products[$key]["manufacturer"]= func_query_first_cell("select manufacturer from $sql_tbl[manufacturers] where manufacturerid=".$product["manufacturerid"]);
}


To get the manufacturer's name to hyperlink, simply use:

Code:

<a href="manufacturers.php/?manufacturerid={$products[product].manufacturerid}">{$products[product].manufacturer}</a>

instead of:

Code:

{$products[product].manufacturer}

where you would like it to show up in skin1/customer/main/products_t.tpl or skin1/customer/main/products.tpl

gastu 12-10-2006 01:01 PM

Re: get manufacture in products.php
 
Quote:

Originally Posted by BCSE
Someone came to me unable to get this code to work on their site and I wasn't able to fix it either so I created another way to do this.

To show the manufacturer on a per product basis on products.php you can also do this instead:

In products.php before:
Code:

$smarty->assign("products",$products);

Insert:
Code:

if($products)
{
        foreach($products as $key=> $product)
                $products[$key]["manufacturer"]= func_query_first_cell("select manufacturer from $sql_tbl[manufacturers] where manufacturerid=".$product["manufacturerid"]);
}


In skin1/customer/main/products_t.tpl or skin1/customer/main/products.tpl insert the following where you want the manufacturer to show up
Code:

{$products[product].manufacturer}

Hope that helps those who are stuck! A bit less code and less files to edit.

Carrie


no work in 4.1.x :(
how can fix?

rbester 12-27-2006 07:28 AM

Re: get manufacture in products.php
 
It did work for us. Thanks!

Also, added the code in featured_products.php (same as in products.php) - so it works on the featured products list as well.

mffowler 08-26-2007 06:27 PM

Re: get manufacture in products.php
 
Thanks Carrie.

- Mike

OpheliaPayne 09-18-2007 09:23 AM

Re: get manufacture in products.php
 
I was unable to get Carrie's code to work in 4.1.8 as well.

zeta1600 11-19-2007 05:30 AM

Re: get manufacture in products.php
 
Quote:

Originally Posted by HWT
To get the manufacturer's name to hyperlink, simply use:

Code:

<a href="manufacturers.php/?manufacturerid={$products[product].manufacturerid}">{$products[product].manufacturer}</a>

instead of:

Code:

{$products[product].manufacturer}

where you would like it to show up in skin1/customer/main/products_t.tpl or skin1/customer/main/products.tpl


I pretty much got this to work, but not the link to the manufacturer. The link isn't resolving. I think because I have XC SEO installed. Can someone show me how to rewrite this? I tried:
<a href="{$products[product].manufacturerid}">{$products[product].manufacturer}</a> But it didn't work.

Also, any way to add the original price (Market price) on the detail page?

zeta1600 11-19-2007 07:30 PM

Re: get manufacture in products.php
 
Got an answer from XC SEO... the code should be without the / after php.

<a href="manufacturers.php?manufacturerid={$products[product].manufacturerid}">{$products[product].manufacturer}</a>

I got this mod to work on both search.php and the products.php. But for product.php (not products.php) I used this code:
<a href="manufacturers.php?manufacturerid={$product.m anufacturerid}">{$manufacturer.manufacturer}</a>

version 08-20-2008 03:21 AM

Re: get manufacture in products.php
 
Quote:

Originally Posted by pmstudios
Make a new function in func.php


Which func.php file are you referring to?

there are about 10 of them in 4.1.10

they all seem to be specific to modules.

dmic 01-30-2014 04:40 AM

Re: get manufacture in products.php
 
Quote:

Originally Posted by pmstudios
Ok, I just checked the method I use since I'm actually doing something similar - not with manufacturers but the idea is exactly same. Do away with everything else and try this...

Make a new function in func.php


Which func.php should this code be added to?

Thanks

Dave

cherie 01-30-2014 06:28 PM

Re: get manufacture in products.php
 
As of 4.1 func.php was broken into specific function files in /include/func, such as func.product.php


All times are GMT -8. The time now is 12:21 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.