Jump to content
radhaumashankar

Display product supplier as a link to its products page.

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

You're welcome !

Report back if this works and / or change to topic to SOLVED.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More