Jump to content

Display supplier name on product page with clickable link


Recommended Posts

<p id="manufacturer" {if !$product_manufacturer->name}style="display: none;"{/if}> <label><b>{l s='Manufacturer:'} </b></label>                  <a href="{$link->getManufacturerLink($product_manufacturer->id_manufacturer, $product_manufacturer->link_rewrite)|escape:'html':'UTF-8'}">
<span>{$product->manufacturer_name|escape:'htmlall':'UTF-8'}</span>
</a>
            </p>

I have used above code for displaying manufacturer name with clickable link (not my own code). If any product has no manufacturer, product page auto hide for manufacturer row. Now I want to display supplier name as like as manufacturer name. Somebody can help me?

Link to comment
Share on other sites

  • 4 weeks later...
You'll need to create override/controllers/front/ProductController.php with the following:
<?php

class ProductController extends ProductControllerCore
{
    public function initContent()
    {
        parent::initContent();
        
        if ((int)$this->product->id_supplier) {
            $this->context->smarty->assign(
                'product_supplier',
                new Supplier((int)$this->product->id_supplier, (int)$this->context->language->id)
            );
        }
    }
}

Remember to go to the Advanced Parameters > Performance tab and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

 

You can then add code like the following on the line before {if !$product->is_virtual && $product->condition} at about 163 of product.tpl:

            {if isset($product_supplier)}
            <p id="product_supplier">
                <label>{l s='Supplier:'} </label>
                {$product_supplier->name}
            </p>
            {/if}
  • Like 1
Link to comment
Share on other sites

One more "little" question:

is possible to traslate the word: Supplier: to Fornitore: ?

I tried to change:

{if isset($product_supplier)}
            <p id="product_supplier">
                <label>{l s='Supplier:'} </label>
                {$product_supplier->name}
            </p>
            {/if}

to:

{if isset($product_supplier)}
            <p id="product_supplier">
                <label>{l s='Fornitore:'} </label>
                {$product_supplier->name}
            </p>
            {/if}

but the output not change the word...

Need to traslate throught Menu--->international--->Translations ?

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...