Displaying more Supplier information on the Product Page in PrestaShop

Displaying more information about a product’s Supplier, directly on the product page, is quite easy in PrestaShop. It only needs an override and a tiny modification to the product template.

Overriding the Product Controller

Unless you want to hard-modify the original ProductController, you would need an override to assign all the necessary Supplier data to your product page.

Create a new file in override/controllers/front, and name it ProductController.php. Open it up and add some generic override code inside php tags:

class ProductController extends ProductControllerCore
{

}

We have to override the initContentMethod

class ProductController extends ProductControllerCore
{
	public function initContent()
	{
		parent::initContent();
	}
}

Make sure you call the parent at the very beginning of it, then add the following inside:

if($this->product->id_supplier)
{
	
	$id_supplier_address = Address::getAddressIdBySupplierId($this->product->id_supplier);
	$supplier_address = new Address($id_supplier_address);
}

First off, we are checking the current product has a supplier. Then, we need its address id, which we use to instantiate a new Address object that contains all of the information we seek.

At this point, we can simply assign all we want to the template:

if (Validate::isLoadedObject($supplier_address))
				{
					$this->context->smarty->assign(array(
						'supplier_country'=>  $supplier_address->country,
						'supplier_company'=>  $supplier_address->company,
						'supplier_address1'=>  $supplier_address->address1,
						'supplier_postcode'=>  $supplier_address->postcode,
						'supplier_city'=>  $supplier_address->city,
						'supplier_phone'=>  $supplier_address->phone,
						'supplier_state' => State::getNameById($supplier_address->id_state),
						'supplier_vat_number'=>  $supplier_address->vat_number,
					));
				}

As an extra measure, we make sure the loaded address object is valid and exists

When you’re done modifying the file, reach the cache/ folder and erase class_index.php

Amending the product template

Now we are ready to display our data. Open product.tpl, located in your theme’s folder. You can choose any spot, I decided to go for the area below the social links in the center column.

			{if $product->id_supplier}
				<h4><a href="{$link->getSupplierLink($product->id_supplier)}"><strong>{$product->supplier_name}</strong></a></h4>
				<ul>
					<li>{$supplier_address1}</li>
					<li>{$supplier_postcode}</li>
					<li>{$supplier_city}, {$supplier_state}</li>
					<li>{$supplier_country}</li>
					{if $supplier_vat_number}
						<li>{$supplier_vat_number}</li>
					{/if}
				</ul>

			{/if}	

I am obviously checking if this product has a supplier, otherwise those variables would not be assigned. Save and refresh, you might need to clear cache in the back office (Advanced Parameters, Performance). We’re done!

Displaying more Supplier information on the Product Page in PrestaShop

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • neeraj bhushan

    Sir, Please give complete ProductController.php of override as single file. I want to show supplier details on my page. Thanks

  • Paintspectrum

    I would like to add a clickable manufacturer in the product information. In an other webshop of me i use the community template, and there its automaticly added. On my main website i use the default template 1.6.1.5

    Is that difficult? I am not a programmer :)

    • NemoPS

      Try with {$link->getManufacturerLink($manufacturer.id_manufacturer)}. Of course use the proper id_manufacturer from your object

  • neeraj bhushan

    I want this thing on my site. Pl. give ProductController.php. as a file . It will be a great help.

  • https://www.denverprophit.us/ Denver Prophit Jr.

    This is a bad idea. Supply chains are usually confidential sources of information. It is why the supplier contact is only shown in the back office. IMHO.

    • NemoPS

      And?
      I’m not saying someone should do it, I’ve just been asked to.

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: