X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Manufacturer name in from of Product name (https://forum.x-cart.com/showthread.php?t=48976)

ADDISON 08-03-2009 10:20 AM

Manufacturer name in from of Product name
 
I need an expert advice on this. I would like to have in all pages {MANUFACTURER NAME} in front of {PRODUCT NAME}.

E.g. ASICS╝ GEL-Nimbus╝ 11 instead of GEL-Nimbus╝ 11.

I can do this editing all tpl files, but it is time consuming. I would like to know in what php file shall I edit to concatenate the product name with manufacturer name.

(product name) = (manufacturer name) . (product name)

X-Cart shows all places product name, and doing this it will be a fast way to put the manufacturer name in front of product name.

Thankx

cflsystems 08-03-2009 11:20 AM

Re: Manufacturer name in from of Product name
 
Don't do this on a live site as I have not tested it

include/func.product.php look for this
Code:

#
# Put all product info into $product array
#

and insert before the end of this function before
Code:

return $product;
}


Code:

$product['product'] = $product['manufacturer'] . " " . $product['product'];

ADDISON 08-03-2009 11:47 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by cflsystems
Don't do this on a live site as I have not tested it

include/func.product.php look for this
Code:

#
# Put all product info into $product array
#

and insert before the end of this function before
Code:

return $product;
}


Code:

$product['product'] = $product['manufacturer'] . " " . $product['product'];


I will follow your advice. But, we have to do a query first to get the manufacturer name in this file. What do you think about?

cflsystems 08-03-2009 12:16 PM

Re: Manufacturer name in from of Product name
 
No. Manufacturer name and id are in there already and part of product array

ADDISON 08-03-2009 10:34 PM

Re: Manufacturer name in from of Product name
 
It's not working. Could you please check too?

Mark Orbit 08-04-2009 01:35 AM

Re: Manufacturer name in from of Product name
 
I've been looking for a solution to this and tried the above with no success. Is there anything else that we need to do? It would be a really cool mod. Thanks in advance.

cflsystems 08-04-2009 05:32 AM

Re: Manufacturer name in from of Product name
 
This is the code you put in include/func/func.product.php just before "return $product"

Code:

$product["product"] = $product['manufacturer'] . " " . $product['product'];

and it will show just like you want it. If you want to manually show it somewhere in skin1/customer/main/product.tpl you call it like this
Code:

{$product.product}
If you want the product title to be with manufacturer name change the first code like this
Code:

$product["producttitle"] = $product['manufacturer'] . " " . $product['product'];

cflsystems 08-04-2009 05:34 AM

Re: Manufacturer name in from of Product name
 
This is the code you put in include/func/func.product.php just before "return $product"

Code:

$product["product"] = $product['manufacturer'] . " " . $product['product'];

and it will show just like you want it. If you want to manually show it somewhere in skin1/customer/main/product.tpl you call it like this
Code:

{$product.product}
If you want the product title to be with manufacturer name change the first code like this
Code:

$product["producttitle"] = $product['manufacturer'] . " " . $product['product'];

Mark Orbit 08-04-2009 06:08 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by cflsystems
This is the code you put in include/func/func.product.php just before "return $product"

Code:

$product["product"] = $product['manufacturer'] . " " . $product['product'];

and it will show just like you want it.


Thanks for your help Steve but isn't this exactly the same as the previous suggestion? (EDIT: I see we have doube quotes now) I have tried it again with no success. I'm on 4.2.2 if that's any help.

Ah... I see it has appeared in the Breadcrumbs. Just the page heading to do now.

Mark Orbit 08-04-2009 08:02 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by cflsystems
This is the code you put in include/func/func.product.php just before "return $product"

Code:

$product["product"] = $product['manufacturer'] . " " . $product['product'];


Assuming that I am following instructions correctly (and I think I am) then this method does appear to cause problems as it affects the admin area aswell...

What happens in my case is the manufacturer name is added into the 'product name' field in the admin EVERY time you make a saved edit in the admin, so I ultimately end up with 'Gibson Gibson Gibson Les Paul Guitar' after three product edits in the admin.

Ideally, I think a solution should not affect the admin or db and just be added at runtime wherever the product name is called on the front end. Any way to do this?

Thanks again for any help. I'm pretty new to XCart with a fairly big project ahead (customised) and I hope it's going to be a fairly logical process once I get the hang of these damn tpl files 8)

carpeperdiem 08-04-2009 08:32 AM

Re: Manufacturer name in from of Product name
 
In my opinion (take that for what it's worth) I would be VERY careful here... and I would edit the templates. There aren't THAT many templates involved... maybe half a dozen?

cflsystems 08-04-2009 08:50 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by Mark Orbit
Assuming that I am following instructions correctly (and I think I am) then this method does appear to cause problems as it affects the admin area aswell...

What happens in my case is the manufacturer name is added into the 'product name' field in the admin EVERY time you make a saved edit in the admin, so I ultimately end up with 'Gibson Gibson Gibson Les Paul Guitar' after three product edits in the admin.

Ideally, I think a solution should not affect the admin or db and just be added at runtime wherever the product name is called on the front end. Any way to do this?

Thanks again for any help. I'm pretty new to XCart with a fairly big project ahead (customised) and I hope it's going to be a fairly logical process once I get the hang of these damn tpl files 8)


Ok I didn't check to see what is affected but that's not the way to go then. So you can either change the php to export to smarty new variable with this value (that way product array won't be affected, but you still have to change the templates to reflect the new variable) or as carpeperdiem posted - change the templates only, which I think you shoud do. Sorry to mislead you like this

ADDISON 08-04-2009 09:27 AM

Re: Manufacturer name in from of Product name
 
Steve, if you checked it and it's working please upload your file (include/func.product.php ). I will make a backup and replace with yours. My X-Cart version is 4.2.2.

Hope an expert will see this and solve the mistery :)

cflsystems 08-04-2009 10:15 AM

Re: Manufacturer name in from of Product name
 
I didn't keep the changes and my version is 4.2.1
If you insist on changing php files... :) open xcart_root/product.php find
Code:

$smarty->assign("location", $location);
and add before
Code:

$new_product_title = $product_info['manufacturer'] . " " . $product_info['product'];
$smarty->assign("new_product_title", $new_product_title);

This will create a new variable and won't mess up with the product array. Then use it in product templates where you want the new title to appear
Code:

{$new_product_title}

ADDISON 08-04-2009 12:30 PM

Re: Manufacturer name in from of Product name
 
Steve, the last solution is ok to me. Thanks for your support.

cflsystems 08-04-2009 03:04 PM

Re: Manufacturer name in from of Product name
 
No problem

Mark Orbit 08-04-2009 03:21 PM

Re: Manufacturer name in from of Product name
 
OK thanks for the tips. That seems an option. If you both recommend to edit the templates then I would rather do that option.

In products_list.tpl we currently have:

HTML Code:

{$product.product|escape}

How would I change this to insert the manufacturer name beforehand. I can of course display the manufacturer ID itself by doing this:

HTML Code:

{$product.manufacturerid} {$product.product|escape}

And the following wouldn't work!
HTML Code:

{$product.manufacturer} {$product.product|escape}

I guess that I'm not far away? Thanks.

carpeperdiem 08-04-2009 03:22 PM

Re: Manufacturer name in from of Product name
 
try,

Code:

{$product.manufacturerid|escape}, {$product.product|escape}

Mark Orbit 08-04-2009 05:09 PM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by carpeperdiem
try,

Code:

{$product.manufacturerid|escape}, {$product.product|escape}


Thanks. That's ok if I want to display the manufacturer ID (1, 2 and so on). How do I modify it to get the actual manufacturer?

carpeperdiem 08-04-2009 05:18 PM

Re: Manufacturer name in from of Product name
 
$product.manufacturer

Mark Orbit 08-05-2009 12:50 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by carpeperdiem
$product.manufacturer


Doesn't work for me I'm afraid. I tried both these options in post #17. Is bringing in the manufacturer more involved than modifying this bit of code? Thanks.

ADDISON 08-05-2009 12:54 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by Mark Orbit
Doesn't work for me I'm afraid. I tried both these options in post #17. Is bringing in the manufacturer more involved than modifying this bit of code? Thanks.


Use post #14. Then you should edit some tpl files. And replace $product.product and $producttitle with your new variable. For the future I will insert an check box in Admin and make some if statements. For example: Do you want Manufacturer name in front of product name?

ADDISON 08-05-2009 12:55 AM

Re: Manufacturer name in from of Product name
 
One more soft question. What is the difference between $product.product and $product.producttitle? Are they the same? Maybe they have same values, using different queries.

Cheers

carpeperdiem 08-05-2009 03:11 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by Mark Orbit
Doesn't work for me


$product.manufacturer is a valid variable in product.tpl

cflsystems 08-05-2009 04:32 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by am2003
One more soft question. What is the difference between $product.product and $product.producttitle? Are they the same? Maybe they have same values, using different queries.

Cheers


$product.product is the value of product field in products table. In func.product.php we find
Code:

$product["producttitle"] = $product['product'];
which make $product.producttitle same as $product.product
What's the reason? I don't know maybe to make it more obvious that this is the product name

Mark Orbit 08-05-2009 05:18 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by carpeperdiem
$product.manufacturer is a valid variable in product.tpl


Does that mean it should work in products_list.tpl (line 29). Is that what you're saying?

Because when I alter:
HTML Code:

{$product.product|escape}
to
HTML Code:

{$product.manufacturer|escape}
it displays nothing at all.

If need be I'll try the method described in #14 but I got the impression that it was not best practice.

cflsystems 08-05-2009 05:34 AM

Re: Manufacturer name in from of Product name
 
product.tpl and products_list.tpl are different templates and $product.manufacturer is not be available in products_list.tpl
You need to edit the php file responsible for populating the products array for products_list.tpl to include manufacturer description in the query

Mark Orbit 08-05-2009 05:37 AM

Re: Manufacturer name in from of Product name
 
Quote:

Originally Posted by cflsystems
product.tpl and products_list.tpl are different templates and $product.manufacturer is not be available in products_list.tpl
You need to edit the php file responsible for populating the products array for products_list.tpl to include manufacturer description in the query


Thanks very much Steve. That makes sense. I'll see how I get on doing that.


All times are GMT -8. The time now is 05:00 AM.

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