mohsart Posted June 4, 2010 Share Posted June 4, 2010 I've looked for a solution of this for a loong time now, but just can't get it to work, and I suspect that there is something fundamental that I just don't get.Say I'd like to show the Manufacturer in the product list, how would I do that? What code in which .php file and what code in product-list.tpl)And the same for if I'd like to show a Feature, say Weight?Thanks!/Mats Link to comment Share on other sites More sharing options...
rocky Posted June 5, 2010 Share Posted June 5, 2010 You can use {$product.manufacturer_name} and {$product.supplier_name} in product-list.tpl to display the manufacturer and supplier names. Unfortunately, product features are not available in product-list.tpl, since it is the getProducts() function in classes/Category.php that gets only some of the product information in an array, rather than as objects that contain all the data. I think this was done to reduce the load time of the product listings. Link to comment Share on other sites More sharing options...
mohsart Posted June 5, 2010 Author Share Posted June 5, 2010 Oh, wow. I thought I tried that, and now I cannot test it because I've got a "hack attempt"...Anyways, regarding the features: how would I do to make them available?Some code in classes/category.php or somewhere else?/Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 5, 2010 Author Share Posted June 5, 2010 Got rid of the hack attempt and it seems OK. Thanks!A side question though: If you look on this page http://mohsart.se/lang-en/bocker-pa-engelska/234-100-tips-for-amateur-players-vol-1.html you see three links of which the two first works the same in this respect (manufacturer is shown in the results list) but the third does not.This is not really of any interest for the functionality, but it got me kind of curious as to why. Is there another .tpl file that is called?This is in product.tpl, of course.Code for second link (working as expected) {l s='Publisher'}: getmanufacturerLink($product->id_manufacturer, $product->link_rewrite)|escape:'htmlall':'UTF-8'}" title="{l s='List books from'} {$product->manufacturer_name|escape:'htmlall':'UTF-8'}">{$product->manufacturer_name|escape:'htmlall':'UTF-8'} Code for third link (not working as expected) {l s='Supplier'}: getsupplierLink($product->id_supplier, $product->link_rewrite)|escape:'htmlall':'UTF-8'}" title="{l s='List books in the series'} {$product->supplier_name|escape:'htmlall':'UTF-8'}">{$product->supplier_name|escape:'htmlall':'UTF-8'} /Mats Link to comment Share on other sites More sharing options...
rocky Posted June 5, 2010 Share Posted June 5, 2010 The reason is that the third page is a supplier page, so it passes in $product.supplier_name instead of $product.manufacturer_name. You'll need to change line 23 of product-list.tpl from: {l s='Publisher'}: {$product.manufacturer_name} to: {l s='Publisher'}: {if $page_name == 'supplier'}{$product.supplier_name}{else}{$product.manufacturer_name}{/if} But I suppose if the supplier is different to the publisher, that won't work. You may need to modify the getProducts() function in classes/Supplier.php so that it gets the manufacturer name like the getProducts() function in classes/Manufacturer.php. Link to comment Share on other sites More sharing options...
mohsart Posted June 6, 2010 Author Share Posted June 6, 2010 Ok, thanks, I kinda get it.As for the main issue though, how would I go about to get hold of the features in product-list.tpl?/Mats Link to comment Share on other sites More sharing options...
rocky Posted June 6, 2010 Share Posted June 6, 2010 You'll need to modify the getProducts() function in classes/Category.php, classes/Manufacturer.php and classes/Supplier.php and add modify the SQL queries so that they get product features. Link to comment Share on other sites More sharing options...
mohsart Posted June 6, 2010 Author Share Posted June 6, 2010 Thanks.I guess I need to dust off my SQL skills, was more than 10 years since I last had to do something more complicated than a simple SELECT...You wouldn't know of somewhere this is done (or something similar) that could help me figuring out how to do it?BTW, what I want to do, exactly, is show tags as well as one feature. Which in my case equals the Author(s) and a rating recommendation respectively for the books I'm selling.But I guess the feature is the most complicated one, so maybe I'll start with the tags.../Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 6, 2010 Author Share Posted June 6, 2010 Am I on the right track with this?category.php: SELECT ... tg.`name` AS tag_name, rk.`value` AS rank, ... LEFT JOIN `'._DB_PREFIX_.'product_tag` tmp ON tmp.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'tag` tg ON tg.`id_tag` = tmp.`id_tag` LEFT JOIN `'._DB_PREFIX_.'feature_product` r ON r.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` rk ON rk.`id_feature_value` = r.`id_feature_value` ... I suspect that it's not good enough for tags, since there can be more than one tag per product, but I expected to get something to show by using {$product.tag_name} {$product.rank} in the tpl file(I only use one feature per product)/Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 7, 2010 Author Share Posted June 7, 2010 Actually, it seems to work. I was looking at the wrong place...However, for everything found (a tag or a feature) the item is duplicated in the list. So still not entierly solved./Mats Link to comment Share on other sites More sharing options...
rocky Posted June 7, 2010 Share Posted June 7, 2010 That's because you forgot to include the id_lang field in the LEFT JOIN statement. You need to change: LEFT JOIN `'._DB_PREFIX_.'tag` tg ON tg.`id_tag` = tmp.`id_tag` to: LEFT JOIN `'._DB_PREFIX_.'tag` tg ON (tg.`id_tag` = tmp.`id_tag` AND tg.`id_lang` = '.intval($id_lang).') and: LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` rk ON rk.`id_feature_value` = r.`id_feature_value` to: LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` rk ON (rk.`id_feature_value` = r.`id_feature_value` AND rk.`id_lang` = '.intval($id_lang).') Link to comment Share on other sites More sharing options...
mohsart Posted June 7, 2010 Author Share Posted June 7, 2010 Great! Thank you so much! :-)The tags part still duplicates the items, but I still need to figure out how to get them into an array so for now I'm happy./Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 7, 2010 Author Share Posted June 7, 2010 I'll have to put the tags issue on hold for the time being. But I wonder one last thing about this.When I do a search I don't see the feature, so I guess another .php file needs the changes also?Also, to have it show up in the home featured page, what file should be changed?Thanks./Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 8, 2010 Author Share Posted June 8, 2010 Homefeatured fixed, but search and new products (and maybe other places, eg specials) don't work.Any ideas?/Mats Link to comment Share on other sites More sharing options...
mohsart Posted June 8, 2010 Author Share Posted June 8, 2010 Sorry for being such a pain in the xxx, but now that it's working in some places it's so frustrating :-/I found another place where it doesn't work: When listing per tag. Maybe it's the same as Search?Working: List per manufacturer, list per Supplier, list Category, HomefeaturedNot working: Search, List per tag, New Products, Specials(?)I've looked through product-sort.tpl, search.tpl, prices-drop.tpl, search.php etc etc but cannot find any apropriate code.../Mats Link to comment Share on other sites More sharing options...
rocky Posted June 9, 2010 Share Posted June 9, 2010 You'll need to modify the queries in the find function of classes/Search.php and the getNewProducts() and getRandomSpecial() functions in classes/Product.php. Link to comment Share on other sites More sharing options...
mohsart Posted June 9, 2010 Author Share Posted June 9, 2010 Great Rocky, you're the best <3/Mats Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now