komodityagro Posted May 26, 2013 Share Posted May 26, 2013 How can I add to product.tpl the supplier - name, adress, phone...? Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share Posted May 26, 2013 it's possible, but modification of the core files is necessary. What prestashop version you use? It's important question in this case. Give me info about your PS version and i will show you how easily add supplier info to product page Link to comment Share on other sites More sharing options...
komodityagro Posted May 26, 2013 Author Share Posted May 26, 2013 I use PS 1.5.4.0... Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share Posted May 26, 2013 okay thanks so open the productController.php file located in your controllers/front/ directory near the 245 line you've got something like: $this->context->smarty->assign(array( 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => ($this->product->customizable) ? $this->product->getCustomizationFields($this->context->language->id) : false, ... add there: 'supplier' => new Supplier($this->product->id_supplier,$this->context->language->id), code should looks like: $this->context->smarty->assign(array( 'supplier' => new Supplier($this->product->id_supplier,$this->context->language->id), 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => ($this->product->customizable) ? $this->product->getCustomizationFields($this->context->language->id) : false, ... then in product.tpl file you can use {$supplier} variable as an object, for example: description: {$supplier->description} name: {$supplier->name} Link to comment Share on other sites More sharing options...
komodityagro Posted May 26, 2013 Author Share Posted May 26, 2013 name: {$supplier->name} is O.K. but description: {$supplier->description} can´t see... Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share Posted May 26, 2013 int the tpl file use {$supplier|print_r} and you will see all available to use variables Link to comment Share on other sites More sharing options...
komodityagro Posted May 26, 2013 Author Share Posted May 26, 2013 It´s any like this: Supplier Object ( [id] => 2 [id_supplier] => 2 [name] => Shure Online Store [description] => [date_add] => 2013-04-01 19:10:12 [date_upd] => 2013-04-01 19:10:12 [link_rewrite] => shure-online-store [meta_title] => [meta_keywords] => [meta_description] => [active] => 1 [webserviceParameters:protected] => Array ( [fields] => Array ( [link_rewrite] => Array ( [sqlId] => link_rewrite ) ) ) [id_lang:protected] => 5 [id_shop:protected] => 1 [id_shop_list] => [get_shop_from_context:protected] => 1 [table:protected] => supplier [identifier:protected] => id_supplier [fieldsRequired:protected] => Array ( [0] => name ) [fieldsSize:protected] => Array ( [name] => 64 ) [fieldsValidate:protected] => Array ( [name] => isCatalogName [date_add] => isDate [date_upd] => isDate ) [fieldsRequiredLang:protected] => Array ( ) [fieldsSizeLang:protected] => Array ( [meta_title] => 128 [meta_description] => 255 [meta_keywords] => 255 ) [fieldsValidateLang:protected] => Array ( [description] => isGenericName [meta_title] => isGenericName [meta_description] => isGenericName [meta_keywords] => isGenericName ) [tables:protected] => Array ( ) [image_dir:protected] => /www/k/o/u20747/public_html/_sub/prestashop/img/su/ [image_format:protected] => jpg [def:protected] => Array ( [table] => supplier [primary] => id_supplier [multilang] => 1 [fields] => Array ( [name] => Array ( [type] => 3 [validate] => isCatalogName [required] => 1 [size] => 64 ) [active] => Array ( [type] => 2 ) [date_add] => Array ( [type] => 5 [validate] => isDate ) [date_upd] => Array ( [type] => 5 [validate] => isDate ) [description] => Array ( [type] => 3 [lang] => 1 [validate] => isGenericName ) [meta_title] => Array ( [type] => 3 [lang] => 1 [validate] => isGenericName [size] => 128 ) [meta_description] => Array ( [type] => 3 [lang] => 1 [validate] => isGenericName [size] => 255 ) [meta_keywords] => Array ( [type] => 3 [lang] => 1 [validate] => isGenericName [size] => 255 ) ) [classname] => Supplier [associations] => Array ( [l] => Array ( [type] => 2 [field] => id_supplier [foreign_field] => id_supplier ) ) ) [update_fields:protected] => ) 1 But I need only contact info - adress, phone, e-mail... Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 27, 2013 Share Posted May 27, 2013 if you set all value in description of supplier than you can use like this variable {$Supplier->description} and get supplier description . Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 if you set all value in description of supplier than you can use like this variable {$Supplier->description} and get supplier description . but he said that he want email address - full contact info.. Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 27, 2013 Share Posted May 27, 2013 but he said that he want email address - full contact info.. yes vekia i told him that if you he set all information inside the description than he can use like that Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 But I don´t know how can I add contact info to product.tpl Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 okay! i've got it ! use this: $address_id=Address::getAddressIdBySupplierId($this->product->id_supplier); $this->context->smarty->assign(array( 'supplier' => new Address($address_id), instead the modification code that i pasted before: $this->context->smarty->assign(array( 'supplier' => new Supplier($this->product->id_supplier,$this->context->language->id), effect: [id_customer] => 0 [id_manufacturer] => 0 [id_supplier] => 1 [id_warehouse] => 0 [id_country] => 21 [id_state] => 32 [country] => United States [alias] => supplier [company] => Apple [lastname] => supplier [firstname] => supplier [address1] => 767 Fifth Ave. [address2] => [postcode] => 10153 [city] => New York [other] => [phone] => (212) 336-1440 [phone_mobile] => [vat_number] => [dni] => [date_add] => 2013-05-25 14:31:36 [date_upd] => 2013-05-25 14:31:36 [deleted] => 0 array with contact informations Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 Thanks but where exactly I have add the codes if I want to appear contact info in product - company, last name, first name, adress1, adress2, postcode, city, phone? Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 (...) so open the productController.php file located in your controllers/front/ directorynear the 245 line... $address_id=Address::getAddressIdBySupplierId($this->product->id_supplier); $this->context->smarty->assign(array( 'supplier' => new Address($address_id), then in product.tpl you will be able to use {$supplier} variable: {$supplier->company} {$supplier->address1} {$supplier->address2} {$supplier->phone} and other variables from array that i pasted above Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 (edited) Well, but in product apears only {$supplier->postcode}, {$supplier->city} and {$supplier->phone} and {$supplier->company}, {$supplier->address1}, {$supplier->address2} are not apear. Why? Hier is ProductController.php code... $address_id=Address::getAddressIdBySupplierId($this->product->id_supplier); $this->context->smarty->assign(array( 'supplier' => new Address($address_id), 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), ...code And hier product.tpl code... <div id="supplier" class="supplier">{$supplier->company} {$supplier->adress1} {$supplier->adress2} {$supplier->postcode} {$supplier->city} {$supplier->phone}</div> {/if} ...code Edited May 27, 2013 by komodityagro (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 maybe you havent got defined those values on supplier edit page? i checked your code, you use: {$supplier->adress1} {$supplier->adress2} it's necessary to use address1 address2 (not adress1 / adress2) Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 Sorry, my mistake... And why not apears {$supplier->company} ? Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 maybe company name isn't defined in language you browse the page? Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 But if I add old code: $this->context->smarty->assign(array( supplier' => new Supplier($this->product->id_supplier,$this->context->language->id), {$supplier->name} appears. By new code $address_id=Address::getAddressIdBySupplierId($this->product->id_supplier); $this->context->smarty->assign(array( 'supplier' => new Address($address_id), {$supplier->name} not appears Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 because you have to use {$supplier->company} here is a full array wit available variables ($supplier->THIS-IS-VARIABLE} [id_customer] => 0 [id_manufacturer] => 0 [id_supplier] => 1 [id_warehouse] => 0 [id_country] => 21 [id_state] => 32 [country] => United States [alias] => supplier [company] => Apple [lastname] => supplier [firstname] => supplier [address1] => 767 Fifth Ave. [address2] => [postcode] => 10153 [city] => New York [other] => [phone] => (212) 336-1440 [phone_mobile] => [vat_number] => [dni] => [date_add] => 2013-05-25 14:31:36 [date_upd] => 2013-05-25 14:31:36 [deleted] => 0 Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 I added {$supplier->company} too but not appears. I don´t understand what is problem... Link to comment Share on other sites More sharing options...
komodityagro Posted May 27, 2013 Author Share Posted May 27, 2013 It is interesting but if I added {$supplier->alias} appears name of the supplier. Now it is perfect!! Vekia thanks for your time and endurance, you are my presta-anjel !! Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 thanks for information that everything works for you now :-) i marked this thread as solved regards Link to comment Share on other sites More sharing options...
Cari Posted November 2, 2013 Share Posted November 2, 2013 Hi I have a question related to this query. How would i add the suppliers country flag to the product list? When i add the variable to show the country, it shows the country ID. Thanks Link to comment Share on other sites More sharing options...
vekia Posted November 4, 2013 Share Posted November 4, 2013 hello countries aren't related to languages in prestashop, but if you use only several countries, you can do it with: upload country flags to /img/l/ directory based on country id field you've got then in product.tpl file use something like: <img src="{$img_lang_dir}{$ID_OF_COUNTRY_VARIABLE_HERE}.jpg" /> Link to comment Share on other sites More sharing options...
Cari Posted November 9, 2013 Share Posted November 9, 2013 hello countries aren't related to languages in prestashop, but if you use only several countries, you can do it with: upload country flags to /img/l/ directory based on country id field you've got then in product.tpl file use something like: <img src="{$img_lang_dir}{$ID_OF_COUNTRY_VARIABLE_HERE}.jpg" /> Hi Thanks so much for your reply! I added: <img src="{$img_lang_dir}{$supplier->id_country}.jpg"/> , however, the URL fails to pick up the country variable.. e.g. "http://mystore.com/img/l/.jpg" Do you know why? Thanks! Link to comment Share on other sites More sharing options...
vekia Posted November 9, 2013 Share Posted November 9, 2013 can you show what you've got in $supplier variable? just put somewhere {$supplier|print_r} Link to comment Share on other sites More sharing options...
Cari Posted November 9, 2013 Share Posted November 9, 2013 Hi Vekia It now shows a '1' near to where i placed the code (this is the ID for English i.e. United Kingdom, well at least i believe so). Link to comment Share on other sites More sharing options...
vekia Posted November 9, 2013 Share Posted November 9, 2013 so it mean that you supplier variable is empty Link to comment Share on other sites More sharing options...
Cari Posted November 9, 2013 Share Posted November 9, 2013 I've fixed it woohoo! You said to put {$supplier|print_r} somewhere, so i put it underneath the code. The '1' was near to the 'image not found' where the flag would be. Since the '1' was there, i put it like this '{$supplier->id_country}{$supplier|print_r}', and the flags now show! Thanks so much for your help, i really appreciate it! Link to comment Share on other sites More sharing options...
Paul de Cocq Posted November 14, 2013 Share Posted November 14, 2013 Hey, This all worked fine for me :-), but i was wondering if it is possible to get some information of the $supplier array into a mail template that goes out to the customer. so if anybody has some suggestions i would really appreciate it. Link to comment Share on other sites More sharing options...
vekia Posted November 14, 2013 Share Posted November 14, 2013 Hey, This all worked fine for me :-), but i was wondering if it is possible to get some information of the $supplier array into a mail template that goes out to the customer. so if anybody has some suggestions i would really appreciate it. if I were you i will create new topic related to emails this thread is a bit different (forum rules: 1 topic = 1 question) im convinced that then someone will help you, for example me Link to comment Share on other sites More sharing options...
Paul de Cocq Posted November 14, 2013 Share Posted November 14, 2013 Ok Thanx I wil open a new topic! Link to comment Share on other sites More sharing options...
hootersam Posted December 11, 2013 Share Posted December 11, 2013 (edited) I have question which expands problem discussed here. I'm using prestashop 1.5.6.1 We can actually assign several suppliers for one product. Lets say its Apple and Shure. And we HAVE TO choose default supplier for that product. Ok lets say its Apple. Now on product page i have in variables only Apple supplier informations. Is there any way to pass object with list of ALL suppliers assigned to this product? (not only one marked as default?) Something like: [suppliers_tab] [1] [supplier id] => 1 [supplier name] => Apple [supplier desc] => ... [2] [supplier id] => 2 [supplier name] => Shure [supplier desc] => .... Let's say i would like to show list of all suppliers for this product on product page. Any help with this? Thanks in advance. Edited December 11, 2013 by hootersam (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts