giwrgos Posted June 18, 2013 Share Posted June 18, 2013 Hello I'm searching a way to add custom fields to the product page on the back office. I was used this example (which is what i'm looking for) but it is for an old version of prestashop http://strife.pl/2011/12/how-to-add-new-custom-field-in-prestashop/ I found also this example which doesn't help because is not english!! http://www.webbax.ch/2011/06/24/comment-ajouter-un-nouveau-champ-sur-la-fiche-produit-et-dans-le-back-office-prestashop/ Does anyone know how i can do the first url on the newest versions of prestashop? Thank you Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 18, 2013 Share Posted June 18, 2013 Hi, may be this article will be helpful for you: http://blog.belvg.com/how-to-create-a-custom-product-tab-in-prestashop.html Regards 1 Link to comment Share on other sites More sharing options...
giwrgos Posted June 18, 2013 Author Share Posted June 18, 2013 Hi, may be this article will be helpful for you: http://blog.belvg.co...prestashop.html Regards thanks a lot but is not! i have saw it too and it doesn't help me Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 18, 2013 Share Posted June 18, 2013 Maybe I am wrong, but you want add some custom fields to your backend. Did I understand you correctly? Link to comment Share on other sites More sharing options...
giwrgos Posted June 18, 2013 Author Share Posted June 18, 2013 yes like this http://strife.pl/2011/12/how-to-add-new-custom-field-in-prestashop/ Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 18, 2013 Share Posted June 18, 2013 Way that described in my article is better. With it you don't need to make changes in core files. Data will be saved in own table, it will make your upgrade easier in future. 1 Link to comment Share on other sites More sharing options...
giwrgos Posted June 19, 2013 Author Share Posted June 19, 2013 Way that described in my article is better. With it you don't need to make changes in core files. Data will be saved in own table, it will make your upgrade easier in future. can you make an example with input field instead of text area? Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 19, 2013 Share Posted June 19, 2013 Yes, sure: Sample.tpl {if isset($belvg_textarea)} <!-- Belvg_SampleModule --> <fieldset style="border:none;"> <input name="belvg_sample" value="{$belvg_textarea}" /> </fieldset> <div class="clear"> </div> <!-- /Belvg_SampleModule --> {/if} Link to comment Share on other sites More sharing options...
giwrgos Posted July 4, 2013 Author Share Posted July 4, 2013 sorry for the delay!! thanks a lot!! Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted July 4, 2013 Share Posted July 4, 2013 Hi, I am a very glad that my solution helped you Link to comment Share on other sites More sharing options...
radomir Posted July 17, 2013 Share Posted July 17, 2013 Hello I realy like your module. Please there are the way how we can show the content in the product list template ? I was trieyed add it in the hook but without any result .. Thank you for reply Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted July 22, 2013 Share Posted July 22, 2013 Hi radomir, there is some example for using hook "ActionProductListOverride". Also you will need to change product-list.tpl of your theme. Regards Link to comment Share on other sites More sharing options...
snejk Posted July 25, 2013 Share Posted July 25, 2013 Hi, may be this article will be helpful for you: http://blog.belvg.co...prestashop.html Regards That's nice, but how I can't prevent to save invalid data and display error? Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted July 26, 2013 Share Posted July 26, 2013 Hi snejk, do you want display error in admin? you can save some errors messages into cookie variable Regards Link to comment Share on other sites More sharing options...
snejk Posted July 26, 2013 Share Posted July 26, 2013 (..) do you want display error in admin? you can save some errors messages into cookie variable Thanks for the reply Yes - display error and prevent updating product in case of invalid value. I'm looking where write error message in $this->context->cookie and Cookie class, but I still don't know where do it? Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted July 26, 2013 Share Posted July 26, 2013 Hi, first of all thank for comment on our blog public function hookActionProductUpdate($params) { ... $this->context->cookie->belvg_pp_errors = NULL; if (!empty($errors) { $this->context->cookie->belvg_pp_errors = $this->displayError($this->l('One of the dates you entered is incorrect')); continue; } ... } public function hookDisplayAdminProductsExtra($params) { ... $this->context->smarty->assign(array( 'belvg_pp_errors' => ((isset($this->context->cookie->belvg_pp_errors) && !empty($this->context->cookie->belvg_pp_errors)) ? $this->context->cookie->belvg_pp_errors : ''), )); ... } after smarty assign, you can display error message in your .tpl file Regards 1 Link to comment Share on other sites More sharing options...
snejk Posted July 26, 2013 Share Posted July 26, 2013 (edited) Hi, first of all thank for comment on our blog (...) I must say, that your tutorials are very helpful Your solution above is a part of my question. I want to keep user in edit page, when input is invalid. Like this case: I have got this error when I trying save product with invalid name. EDIT: Finally, I found solution with overriding controller. mymodule/mymodule.php public function hookActionProductUpdate($params) { // validation values code here Configuration::updateValue('MYMODULE_VALID', $valid); } mymodule/override/controllers/admin/AdminProductsController.php class AdminProductsController extends AdminProductsControllerCore { public function checkProduct() { if( Configuration::get('MYMODULE_VALID') ) $this->errors[] = Tools::displayError('Error msg'); return parent::checkProduct(); } Changes appear after install/reinstall module. Edited July 26, 2013 by snejk (see edit history) Link to comment Share on other sites More sharing options...
connemb Posted September 19, 2013 Share Posted September 19, 2013 How would you go about adding multiple textarea fields to the backside and having them update? Link to comment Share on other sites More sharing options...
Imran ull Hassan Posted October 8, 2013 Share Posted October 8, 2013 (edited) thank its a great module Edited October 8, 2013 by Imran ull Hassan (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted October 9, 2013 Share Posted October 9, 2013 Thanks to all, I am really pleased read it. 1 Link to comment Share on other sites More sharing options...
mirapresta Posted October 19, 2013 Share Posted October 19, 2013 Hello Everyone I am struggling with an issue here. Hope a prestashop expert can help me out. I want to create a custom form with drop down list in product page and send the data to cart just as the product customization details are sent. I have created the form but I don't know the code that should be put to send the form data/details to the cart. Please can anyone help me?? I am a newbie and m lost. Please help. Thanks so much. Mira Link to comment Share on other sites More sharing options...
motzel Posted October 30, 2013 Share Posted October 30, 2013 Way that described in my article is better. With it you don't need to make changes in core files. Data will be saved in own table, it will make your upgrade easier in future. Is it possible to rename a tab? Right now it's using a module name, I'd like to change it to something else without changing module name. Thanks in advance! Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 31, 2013 Share Posted October 31, 2013 Hello Everyone I am struggling with an issue here. Hope a prestashop expert can help me out. I want to create a custom form with drop down list in product page and send the data to cart just as the product customization details are sent. I have created the form but I don't know the code that should be put to send the form data/details to the cart. Please can anyone help me?? I am a newbie and m lost. Please help. Thanks so much. Mira Is it possible to rename a tab? Right now it's using a module name, I'd like to change it to something else without changing module name. Thanks in advance! First ... help yourself, don't post out of topic. Then believe me ... there are a lot of prestashop user within this forum who happy to help you Link to comment Share on other sites More sharing options...
motzel Posted November 4, 2013 Share Posted November 4, 2013 First ... help yourself, don't post out of topic. Then believe me ... there are a lot of prestashop user within this forum who happy to help you Why do you think my question was out of topic? Alexander Simonchik has replied to original post author and has shown a better way to add custom field to product in PS1.5. I'm using a method he's presented, but there is a small problem with that - it creates a tab in product edit page and that tab is named according to module name. So I asked Alexander if it's possible to rename it to something else (and quoted a right post). No offence, as I don't want to start a flame here, but after my explanation do you still think that my question was out of topic? Link to comment Share on other sites More sharing options...
vekia Posted November 4, 2013 Share Posted November 4, 2013 you will need to rename the module Link to comment Share on other sites More sharing options...
motzel Posted November 4, 2013 Share Posted November 4, 2013 (edited) you will need to rename the module That's an easy way I'd like to have one name in modules list and another in tab name. Is it possible to change it without renaming the module? I've looked at the PS sources, but it looks like it's a mission impossible :-( Edited November 4, 2013 by motzel (see edit history) Link to comment Share on other sites More sharing options...
magicska Posted May 26, 2014 Share Posted May 26, 2014 Hi, i've added a new custom filed in back end using newfieldstut module, it add a new coloumn in prodouct_lang table. It work fine only in product-list.tpl <a itemprop="url" class="btn btn-default" href="{$product.custom_field}">Vedi la demo Live{$product.custom_field}</a></div> but not work in product.tpl <a class="btn btn-default" href="{$product->custom_field}">Vedi la demo Live</a></div> why? Link to comment Share on other sites More sharing options...
diwasas Posted August 29, 2014 Share Posted August 29, 2014 (edited) I'm using this free module sample to add new video url field to the product. Everything works fine, I can see new data in product.tpl, but I cant get data to product-list.tpl what is very important to me, I want to add play button to each product. I found that for this purpose I have to use hookActionProductListOverride function but no luck with that. Anyone can help me? public function hookDisplayAdminProductsExtra($params) { $id_product = Tools::getValue('id_product'); $sampleObj = Belvg_Sample::loadByIdProduct($id_product); if(!empty($sampleObj) && isset($sampleObj->id)){ $this->context->smarty->assign(array( 'belvg_textarea' => $sampleObj->textarea, )); } return $this->display(__FILE__, 'views/admin/sample.tpl'); } public function hookActionProductUpdate($params) { $id_product = Tools::getValue('id_product'); $sampleObj = Belvg_Sample::loadByIdProduct($id_product); $sampleObj->textarea = Tools::getValue('belvg_sample'); $sampleObj->id_product = $id_product; if(!empty($sampleObj) && isset($sampleObj->id)){ $sampleObj->update(); } else { $sampleObj->add(); } } public function hookDisplayFooterProduct($params) { $id_product = Tools::getValue('id_product'); $sampleObj = Belvg_Sample::loadByIdProduct($id_product); if(!empty($sampleObj) && isset($sampleObj->id)){ $this->context->smarty->assign(array( 'belvg_textarea' => $sampleObj->textarea, )); } echo $sampleObj->textarea; } } Edited August 29, 2014 by diwasas (see edit history) Link to comment Share on other sites More sharing options...
Denver Prophit Jr. Posted November 25, 2014 Share Posted November 25, 2014 Alex Simonchik BelVG, I was looking at http://schema.org/Offer for the parameter category which could be http://schema.org/Thing with an additionalType parameter to define the category from say goodrelations or use the sameAs field to define the prototypycal classifcation the semantic category concept. Using the default template and hooks in the category creation menu, how would you see extending prestashop further for semantic SEO? Link to comment Share on other sites More sharing options...
WebMadeFun Posted December 1, 2014 Share Posted December 1, 2014 First of all a big big thank you to Alex Simonchik BelVG This module saved me a lot of hours working! I would like to add few notes for those who need to add save buttons on the end of the admin buttons and enable the tinymce editor HOW TO ADD SAVE BUTTONS Open the /views/admin/sample.tpl file and at the bottom of the file place this piece of code <div class="panel-footer"> <a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}" class="btn btn-default"><i class="process-icon-cancel"></i> {l s='Cancel'}</a> <button type="submit" name="submitAddproduct" class="btn btn-default pull-right"><i class="process-icon-save"></i> {l s='Save'}</button> <button type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right"><i class="process-icon-save"></i> {l s='Save and stay'}</button> </div> HOW TO TURN ON THE TinyMCE EDITOR 1. On the /views/admin/sample.tpl file replace the <textarea>.... </textarea> piece of code with this <textarea class="autoload_rte" name="belvg_sample" rows="10" cols="45">{if isset($belvg_textarea)}{$belvg_textarea}{/if}</textarea> 2. On the /views/front/sample.tpl replace the code that you see there with this (actually you just remove some piece of coding but I am pasting the entire code in order to avoid confusions) {if isset($belvg_textarea)} <!-- Belvg_SampleModule --> {$belvg_textarea} <div class="clear"> </div> <!-- /Belvg_SampleModule --> {/if} And here is the new back office http://prntscr.com/5c3x98 and live shop http://prntscr.com/5c3xu6 (I didn't hooked it yet to the right position, I just wanted to show you how it looks) Prestashop version 1.6.0.9 Link to comment Share on other sites More sharing options...
wakabayashi Posted January 3, 2017 Share Posted January 3, 2017 Alex, thanks a lot for this tutorial/module! It still works like a charme. I have a question. I would like to display the custom field on invoice, when a product is ordered. Is this hard to achieve? Somebody can tell me how this works? Regards Emanuel 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