![]() |
get manufacture in products.php
I'm trying to call the manufacture of a product in products.php so it is accessible in the smarty template customer/main/products.tpl
as {$products[product].manufacture} or something similar. I've dead-ended 2 of my previous attempts to get this to work, has anyone done something similar before, or have any ideas on how to go about it? x-cart 4.0.5 PHP 4.3.9 MySQL 4.0.20-standard Linux I really appreciate any advice Justin |
You would have to merge two arrays or create one specifically for manufactures and just use it with the products array. And manufacturers have their own table, so you would need to use the manufactureid from the products table.
Something like this Code:
foreach ($products as $k => $v) { Example of use in products.tpl Code:
{section name=product loop=$products} Sorry for the rugged example. This should set you in the right direction at least, if it doesn't work. |
I'll preface this by saying I'm no PHP expert, I can usually take care of the task at hand, but this x-cart install is my first venture into SQL, everything I've done before has been PHP with flat text files.
That said, I'm getting a parse error in products.php It looks to me like it's a quotes issue after WHERE manufactureid= My attempts resolve it continue to produce an error too, so perhaps I'm wrong about that. Does anythings stand out to you? Quote:
|
You're right jds580s,
Here's the fixed query Code:
$manufacturers = func_query("SELECT $sql_tbl[manufacturers].* FROM $sql_tbl[manufacturers]" WHERE manufacturerid='".$products[$k]["manufacturerid"]."'"); |
OK, I've almost got this working, it will correctly display the manufactures name of the first product in a catagory, but none of the subsiquent one.
for anyone else who references this I modified at least one or two things here in products.php Code:
foreach ($products as $k => $v) { and simplified the products_t.tpl code for my needs Code:
{if $products[product].manufacturerid ne "0"}{$manufacturers[product].manufacturer}{/if} Any ideas on why products after the first don't display? The conditional statement in the .tpl file is correct, when I put some text in there it is "true" for all the products that have a manufacture set, it's just the $manufacturers[product].manufacturer that is only working on the first product. Thanks! |
I thought that may happen..
Try adding a new section loop for the $manufacturers array. Code:
{section name=id loop=$manufacturers} |
Ok, closer still... now it displays the manufacture for all the items that have the same manuf as the last item in the list.
this code also displays the manufacture id number "manid" to help me identify what id is with what product Code:
{if $products[product].manufacturerid ne "0"} you can see what this looks like http://www.yarnsmith.co.uk/xcart/home.php?cat=3 the first item's manufacture is Katia manid=6 |
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 Code:
function func_get_manufacturers($manufacturerid) { In products.php Code:
if ($products) { In products.tpl just use Code:
{$manufacturers[product].manufacturer} That should work. If not, I'll resign and bake donuts from now on :lol: |
This seems a little more streamlined, and puts a manufacture at the top of each product... but it looks like the first product is manufacture1 second product is manufacture2 and so on.
http://www.yarnsmith.co.uk/xcart/home.php?cat=3 see example looks like instead of checking the manufacture ID against the name it is taking the number of the foreach loop that it is on. |
Ok, then in the template add the if statement
Code:
{if $manufacturers[product].manufacturerid eq $products[product].manufacturerid} should solve the problem... |
For anyone else reading this I made one other small change and it is working like a charm
in products(_t).tpl I change the code to Code:
{*** ########## Lines below to display manufacture name ########## ***} Before it was returning manufacture name based on the current loop number. And not it doesn't display anything if there is no manufacture set for a product. Thanks pmstudios for all the help! |
Ok, i'm also interested to display the Manufacture, but instead of the Products (customer/main/products.tpl) I want to display it on the actual Product Page (customer/main/product.tpl).
All I want to do is have is something as simple as: Manufacture: Sony Can some please help with what code to insert into the template file? Thank you... |
Quote:
In product.php, near the bottom (add lines marked with +) Code:
$smarty->assign("product",$product_info); In customer/product.tpl, use {$manufacturer.manufacturer} to display it... |
thank you very much! Works a charm
i just don't understand why that option wasn't standard. |
In customer/product.tpl, use {$manufacturer.manufacturer} to display it...
Where do I place {$manufacturer.manufacturer} within the code of the customer/main/product.tpl page? Do I need to put it within any other code? |
That shouldn't need to go any place in particular.
Typically it would be between the {capture} and {/capture} near the top and bottom of the file |
Quote:
You can put it anywhere. The product info page is product specific, so the script selects the manufacturer of that product. |
OK
You have to place it within the template at the spot on the page where you want it to show up. If you place it at the bottom of product.tpl it will show up after all of the other tables on the page. It works great! Thanks |
That did work great. Just what I wanted.....except.. I would like to also add the SKU in the same place...product.tpl.
Can anyone give me the code to add? Thanks, Dalmuti |
Quote:
You should be able to reference it by just using {$product.productcode} as it's already included in the select product query. |
Perfect! Got it done. Appreciate the help!
Dalmuti |
Quote:
Could anybody post the variant that instead of saying Manufacturer:Timex It will show the brandlogo, something like Timex.gif (brand logo) else Timex (text) To me the customer recognize faster the logo than the name . Also, how can I change the manufacturer.php so it will put the brandlogos and names in several columns, instead of one column name. With an output like this: http://www.makeitfast.com/default.php?manufacturers_id=11 |
Manufacturer logo?
How about a manufacturer logo?
How can I place the manufacturer's logo above the product tile? I am kind of envious of newegg.com I like how the manufacturer logo appears with the products. Thanks in advance. |
Re: Manufacturer logo?
Quote:
Basically the same exact method, but instead use {$manufacturer.image} Make sure you have image included in the SELECT query too. |
Quote:
Sorry, how do you go about doing this ? Here is the MySQL table fields: Full Texts manufacturerid manufacturer url image image_type descr orderby provider avail Thanks for a great mod ! |
Quote:
Modify the code added in product.php so the query looks like this: Code:
$manufacturer = func_query_first("SELECT manufacturer,image FROM $sql_tbl[manufacturers] WHERE manufacturerid='$product_info[manufacturerid]'"); Quote:
And you're welcome :) |
great work pmstudios!
I've just started out on PHP so please forgive my noobness As for Code:
{manufacturer.image} Here's what I've done for displaying manufacturer's image: in products.tpl to display image: Code:
[img]mlogo.php?manufacturerid={$manufacturerid.manufacturerid}[/img] to display the manufacturer name and a link that display other products by the manufacturer: in product.php Code:
$manufacturer = func_query_first("SELECT manufacturer,image,image_type,manufacturerid FROM $sql_tbl[manufacturers] WHERE manufacturerid='$product_info[manufacturerid]'"); Thanks again pmstudios for an excellent code! |
I am sorry to ask, but i am having no luck on getting this to work for me, I have to be missing somthing....
In my Product.php file I added this code : Code:
# Manufacturers Logo In Products And added this to my Product.Tpl file : Code:
[img]mlogo.php?manufacturerid={$manufacturerid.manufacturerid}[/img] Pretty much as directed. But still no luck. My product template does display the Xcart image place holder but not the manufacturers Logo. Any help is greatly appreciated. Jason |
Hey MPJ, it is in products.tpl or product.tpl
In the other post they are talking about product.tpl Hey Vortex, can you post your code, is exactly what I want to do, put the logo at the top, and the text under the image product. |
Bump-o-
|
Ok I got it:
instead of Quote:
It should be: Quote:
|
Manfacturer Name and Link in Products List
I am trying to get the manfucturer name to display on the products listing page. I have done the following:
========================================== Make a new function in func.php Code: function func_get_manufacturers($manufacturerid) { global $sql_tbl; return func_query("SELECT $sql_tbl[manufacturers].* FROM $sql_tbl[manufacturers] WHERE manufacturerid='$manufacturerid'"); } In products.php Code: if ($products) { foreach ($products as $k => $v) $manufacturers[] = func_get_manufacturers($v["manufacturerid"]); } $smarty->assign("manufacturers", $manufacturers); In products.tpl just use Code: {*** ########## Lines below to display manufacture name ########## ***} {assign var="manid" value=$products[product].manufacturerid} {if $manufacturers[$manid].manufacturerid ne "0"} <FONT class="ItemsList">{$manufacturers[$manid].manufacturer}</FONT> {/if} {*** ########## End display manufacture name ########## ***} ========================================== The problem I am having is the the link shows the incorrect manufacturer name, but when I click on the link it takes me to the correct manufacturer page. Thanks David X-Cart version 4.0.12 PHP 4.3.10 MySQL server 4.0.23-nt-max MySQL client 3.23.49 Web server Microsoft-IIS/6.0 Operation system Windows XML parser (expat) 1.95.6 |
This is the way it works for me:
In product.php before the smarty assigns Quote:
In product.tpl you have to play different positions that you'll like to see it display You can use this one: Quote:
or you can use yours. Forget about the func.php |
Hello
I've been working my way through this thread and managed to get the manufacturer displaying items on the product page (product.tpl) and the product list (products.tpl) - thanks very much to pmstudios and jds580s for that. You've helped me get my head round xcart quite a bit with your posts. However, I can only get the manufacturer to display per product. In fact I want to display all the products for a manufacturer. I think this might need to be done in products_t.tpl but I can't really work out what's going on in there. In fact I really want the manufacturer to be a subcategory but that doesn't seem to be an option. Any help with this would be greatly appreciated. Davros |
You mean:
http://www.your-domain.com/manufacturers.php |
No - manufacturers.php just gives a list of _all_ manufacturers. I want to list the items by manufacturer for each category.
So when I go to home.php?cat=1 I want Category 1 Manufacturer 1 item 1 item 3 Manufacturer 2 item 2 item 4 item 5 etc At the moment I get Category 1 item 1 - manufacturer 1 item 2 - manufacturer 2 item 3 - manufacturer 1 item 4 - manufacturer 2 item 5 - manufacturer 2 Does that make sense? |
You can do that manually, you create the category, your subcategories will be the name of the manufacturers or brands, and then you assign the products to each one, also you can put a logo to each of the subcategories(brands). Also you can use one of the mod's that handle subcategories for your products presentation.
Hope this help. |
Re: Manfacturer Name and Link in Products List
Quote:
Just a summary of things we did to show manufacturer name in the list of products (thanks to pmstudios and jds580s) add to include/func.php Code:
# in products.php before this line: Code:
$smarty->assign("products",$products); add Code:
# in customer/main/products.tpl or customer/main/products_t.tpl: after Code:
<FONT class="ProductTitle">{$products[product].product}</FONT></A> add Code:
{* show Manufacturer name *} Example is here: http://www.reach4life.com/store/home.php?cat=554 |
Hey 27stars, I'm glad that you convinced them to change to x-cart. I used to have their old shopping cart too.
|
I cannot get this code to work for me. I have followed all the different variations that many of you have placed in this thread, but can't any of them to work.
Here is my thread, any help would be appreciated! http://forum.x-cart.com/viewtopic.php?t=20524 Brian |
All times are GMT -8. The time now is 06:23 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.