radhaumashankar Posted July 8, 2017 Share Posted July 8, 2017 Hi guys, I want to display the supplier name in products detail page as a link to its product page. I mean it should direct me to page of products that has same Supplier. please help,i despirately want to achieve this. Link to comment Share on other sites More sharing options...
Scully Posted July 9, 2017 Share Posted July 9, 2017 (edited) You need to change the product.tpl file in your themes directory. The following code is from suppliers-list.tpl. It won't work exactly this way but points you to the direction you have to go. It is also possible that you have to make some smaller changes in the product controller (ProductController.php) to fetch the supplier name and hand it over via smarty variable to the product.tpl file. Code from supplier-list.tpl {if isset($supplier.nb_products) && $supplier.nb_products > 0} <a href="{$link->getsupplierLink($supplier.id_supplier, $supplier.link_rewrite)|escape:'html':'UTF-8'}" title="{$supplier.name|escape:'html':'UTF-8'}"> {/if} Edited July 9, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted July 9, 2017 Share Posted July 9, 2017 Or to get the suppliers name to display within the link, try to use the following function from suppliers class: public static function getNameById() so the code in tpl could look like this: {if isset($product->id_supplier) && $product->id_supplier > 0} <a href="{$link->getsupplierLink($product->id_supplier)|escape:'html':'UTF-8'}"> {Supplier::getNameById($product->id_supplier)} </a> {/if} Untested, quick and dirty. 1 Link to comment Share on other sites More sharing options...
radhaumashankar Posted July 9, 2017 Author Share Posted July 9, 2017 thank you so much Link to comment Share on other sites More sharing options...
Scully Posted July 9, 2017 Share Posted July 9, 2017 You're welcome ! Report back if this works and / or change to topic to SOLVED. Link to comment Share on other sites More sharing options...
mausbaus Posted March 8, 2019 Share Posted March 8, 2019 (edited) On 7/9/2017 at 12:54 PM, Scully said: {if isset($product->id_supplier) && $product->id_supplier > 0} <a href="{$link->getsupplierLink($product->id_supplier)|escape:'html':'UTF-8'}"> {Supplier::getNameById($product->id_supplier)} </a> {/if} @Scully Glad to have found your answer after 2h of searching. 💋 {if $product.id_supplier} <a href="{$link->getSupplierLink($product.id_supplier)}">{Supplier::getNameById($product->id_supplier)}</a> {/if} Works wonderful in 1.7.5 as well. The missing piece was how to get the supplier name since $product_supplier->name was not working... Edited March 8, 2019 by mausbaus (see edit history) 1 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