Attrexx Posted October 24, 2016 Share Posted October 24, 2016 (edited) 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 October 24, 2016 by Attrexx (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 25, 2016 Share Posted October 25, 2016 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. 1 Link to comment Share on other sites More sharing options...
Attrexx Posted October 25, 2016 Author Share Posted October 25, 2016 (edited) Solution makes perfect sense but does not output anything :/Maybe I'm not using the right variable?Used these two: {$product.supplier_Address1} and {$supplier->Address1} Edited October 25, 2016 by Attrexx (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 26, 2016 Share Posted October 26, 2016 You can't access the address from the $supplier object. You should use the $supplier_address object instead. For example, {$supplier_address->address1}. Link to comment Share on other sites More sharing options...
Attrexx Posted November 1, 2016 Author Share Posted November 1, 2016 Still no output Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2016 Share Posted November 2, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now