Jump to content

Supplier country, address variables on Product List


Attrexx

Recommended Posts

Hello, I am trying to display on Category page, on every product, the country of its associated Supplier.

 

I have added the following both in ProductController.php and in CategoryController.php:
 

$address_id=Address::getAddressIdBySupplierId($this->product->id_supplier);
			$this->context->smarty->assign(array(
	   			'supplier' => new Address($address_id),
				'supplier' => new Supplier($this->product->id_supplier,$this->context->language->id),

Tried various variable formats, none output anything:

 

{$product->supplier_country}

{$product->supplier_address1}

{$supplier->country}

{$supplier->address1}

 

Not even {$product->supplier_name}, {$supplier->alias} or {Supplier::getNameById($product->id_supplier)} work :(

 

It's like I can't get ANY supplier info, as opposed to Manufacturers which works fine.

 

The page I'm working on is this: http://fashion-futures.uk/13-women

First product has Supplier associated, others don't. The "C-" text output is there to mark where Supplier Country should appear.

 

TPL code is this one:

<div class="designer-bg-cat"> <img src="{$img_manu_dir}{$product.id_manufacturer}-small_default.jpg" class="manu-img" alt="{$product.manufacturer_name}" title="{$product.manufacturer_name}" />
<p style="  color: #DB0048;  padding-left: 91px;  font-size: 16px;  margin-top: 4px;  font-family: 'Lato';  /* font-weight: 100; */">Designer <br/>
<span class="designer"><a class="designer" href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$product.manufacturer_name|escape:'htmlall':'UTF-8'}">{$product.manufacturer_name|escape:'htmlall':'UTF-8'}</a></span><br/>
<span title="{$manufacturer->description|escape:'htmlall':'UTF-8'}">C - {$supplier->alias|escape:'htmlall':'UTF-8'}</span>
</p>
</div>

Any help would be greatly appreciated guys :(

Edited by Attrexx (see edit history)
Link to comment
Share on other sites

Try changing:
'supplier' => new Address($address_id),
'supplier' => new Supplier($this->product->id_supplier,$this->context->language->id),

to:

'supplier_address' => new Address($address_id),
'supplier' => new Supplier($this->product->id_supplier, $this->context->language->id, $this->context->shop->id),

It seems you accidentally assigns two variables the same name, so I changed the first to $supplier_address. I also added the shop ID to the Supplier constructor so it gets just the supplier of the current shop.

  • Like 1
Link to comment
Share on other sites

I don't understand why it's not working for you. I tried creating test.php in the root directory of my PrestaShop v1.6.1.8 test site with the following:

<?php

include('config/config.inc.php');

$supplier_address = new Address(2);
echo $supplier_address->address1;

Maybe you can try the same? Change 2 to the ID of an address that has 1 in the id_supplier column.

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