Jump to content

Display product supplier as a link to its products page.


radhaumashankar

Recommended Posts

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 by Scully (see edit history)
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
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 by mausbaus (see edit history)
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...