giancarlo.spadini Posted August 30, 2013 Share Posted August 30, 2013 I'm developing a module to import data from an external wholesales to PrestaShop. I have a problem validating field product->description when contains some particular HTML tags. When HTML description contains tag object <object></object> I receive this error: [PrestaShopException] Property Product->description is not valid at line 878 in file classes/ObjectModel.php 872. 873. $message = $this->validateField($field, $value, $id_lang); 874. if ($message !== true) 875. { 876. if ($die) 877. throw new PrestaShopException($message); 878. return $error_return ? $message : false; 879. } 880. } 881. } 882. So, is possible setup PrestaShop to accept HTML description with this tag? There is a list of HTML tag that can't be used? Thanks Link to comment Share on other sites More sharing options...
jgullstr Posted August 30, 2013 Share Posted August 30, 2013 Hello, The validator used on product descriptions is Validator::isString() (which is only a wrapper for PHP's is_string() method). You could run that method manually on the string to check if it validates. Another reason might be incompatible text encodings. Also, as the description is a multilanguage field, remember to construct it accordingly. Example: $product->description = array(); foreach (Language::getLanguages(false) as $lang){ $product->description[$lang['id_lang']] = $[your description source]; } Link to comment Share on other sites More sharing options...
giancarlo.spadini Posted August 30, 2013 Author Share Posted August 30, 2013 (edited) Dear jgullstr, thank you for your reply. I have searched in PS classes to understand why field product->description fails when contains some tags. Is not only a string check. This field can contains HTML codes. I notice that is validated with this function: isCleanHtml() in class Validate.php at line 405 there is this check: if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) My descriptions contains object and embed tags to display videos from YouTube. So i need these "not clean" tags. I want to try to enable iframe tag ($allow_iframe). Someone knows where can i set this information? Edited August 30, 2013 by giancarlo.spadini (see edit history) Link to comment Share on other sites More sharing options...
jgullstr Posted August 30, 2013 Share Posted August 30, 2013 Which PS version are you using? Link to comment Share on other sites More sharing options...
vekia Posted August 31, 2013 Share Posted August 31, 2013 can you check this: preferences > General there is option: you need to switch it to "Yes" 5 Link to comment Share on other sites More sharing options...
giancarlo.spadini Posted August 31, 2013 Author Share Posted August 31, 2013 Switching to YES allow iframes solved this problem. This a limit to the label that describes this switch. If is set to yes, become valid all these tags: iframe|form|input|embed|object Link to comment Share on other sites More sharing options...
giancarlo.spadini Posted September 1, 2013 Author Share Posted September 1, 2013 Which PS version are you using? For documentation: i'm using version 1.5.5.0 Link to comment Share on other sites More sharing options...
vekia Posted September 1, 2013 Share Posted September 1, 2013 thanks for all informations, im going to mark this topic as [sOLVED] best regards Link to comment Share on other sites More sharing options...
Zitoun Posted September 7, 2013 Share Posted September 7, 2013 (edited) Good evening, I got the same problem with categories descriptions, for which I can't insert youtube videos with iframes. Changing "allow iframes" parameter does not solve this problem for categories. Have you please an idea ? Thanks a lot in advance. Edited September 7, 2013 by Zitoun (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted September 7, 2013 Share Posted September 7, 2013 hello may i know how you add iframe ? with tinymce feature or you just pasting code? Link to comment Share on other sites More sharing options...
Zitoun Posted September 8, 2013 Share Posted September 8, 2013 (edited) Good morning, Yes I do use tinyMCE and insert youtube provided code in HTML or with button "insert media" which result in the same: <p><iframe src="//www.youtube.com/embed/XXXXXXXXXXXXX" frameborder="0" width="560" height="315"></iframe></p> For the time being to go on working, I solved this with a dirty trick by changing classes\Validate.php line 392 : $allow_iframe = true Thanks a lot in advance. Edited September 8, 2013 by Zitoun (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted September 8, 2013 Share Posted September 8, 2013 thanks for your solution, may i ask for something? what ps version you use? Link to comment Share on other sites More sharing options...
Zitoun Posted September 8, 2013 Share Posted September 8, 2013 I updated to PS1.5.5, and got a few problems among them this one (Unfortunaltely this is the case for nearly every updates). And this is not a clean solution, isn'it ? Link to comment Share on other sites More sharing options...
vekia Posted September 8, 2013 Share Posted September 8, 2013 well, if it works - everything is okay. I suppose, that if you in nearest future will upgrade your store (to 1.6 for example) - you will have to change it once again Link to comment Share on other sites More sharing options...
Zitoun Posted September 8, 2013 Share Posted September 8, 2013 There have been more than 5 releases of PS this year, and every time, I have to spend around a day or more on forums searches and doing again and again the same corrections, instead of the half hour or so advertised for upgrades. So this is unfortunately not satisfactory, also it will indeed do for the moment. Thanks. Link to comment Share on other sites More sharing options...
jgullstr Posted September 8, 2013 Share Posted September 8, 2013 If you want a more clean solution, you can override the Validate class. Paste the following into a new file called Validate.php in your PS_ROOT/override/classes folder. Then clear the class index by deleting class_index.php in the PS_ROOT/cache folder. <?php class Validate extends ValidateCore { public static function isCleanHtml($html, $allow_iframe = true) { return parent::isCleanHtml($html, $allow_iframe); } } By using this method instead, chances are an upgrade wont break the fix, and if it will, you can see what changes you have made by browsing the override folder (If you, as me, are not keen on documenting each and every fix). I usually create a module that contains shop-specific overrides, in order to better keep track of my core "hacks", to allow for smoother upgrading. Link to comment Share on other sites More sharing options...
Zitoun Posted September 8, 2013 Share Posted September 8, 2013 (edited) Thank you very much for this precise answer, and sharing your methodology, also I did not understand your suggestion on new modules (I am not yet able to build new modules, nor have need for it). Yes overriding is much cleaner according to PS logic, and also reluctant, I did a few overrides too on controllers ("CategoryController.php" and "CmsController.php" for egg to enable galleries or generate new images sizes), though not yet classes. I do that and also keep tracks on a WORD workbook. But it is time consuming every 2 months to upgrade, especially compared to Wordpress, were upgrades run smoothly in seconds. The main problem with overrides or templates based on default, is that if PS do upgrade even slightly the overrided items, our installation will not benefit from it. PS : thank you again for the code: for overriding, I would have copied the whole function, since I am not a php expert. Edited September 8, 2013 by Zitoun (see edit history) Link to comment Share on other sites More sharing options...
jgullstr Posted September 8, 2013 Share Posted September 8, 2013 Glad to help I got some ideas on override management from this thread. I'm going to pry around in core and, if plausible, write a module that hopefully will help a bit with these issues while they exist. Link to comment Share on other sites More sharing options...
jgullstr Posted September 9, 2013 Share Posted September 9, 2013 Glad to help I got some ideas on override management from this thread. I'm going to pry around in core and, if plausible, write a module that hopefully will help a bit with these issues while they exist. Slightly off-topic: Here's the result of what i came up with to help keep track of your overrides from backoffice. http://www.prestashop.com/forums/topic/273789-module-override-manager-ps-15/ 1 Link to comment Share on other sites More sharing options...
vekia Posted September 9, 2013 Share Posted September 9, 2013 looks interesting & promising, thanks for url Link to comment Share on other sites More sharing options...
lixotuka Posted September 30, 2013 Share Posted September 30, 2013 can you check this: preferences > General there is option: you need to switch it to "Yes" Thanks a million Link to comment Share on other sites More sharing options...
vekia Posted September 30, 2013 Share Posted September 30, 2013 hello this is new feature in prestashop 1.5.5, so everyone who updaing own store from older version have to switch this option Link to comment Share on other sites More sharing options...
josias Posted September 30, 2013 Share Posted September 30, 2013 I have the same problem, but changing the option to "allow iframes" is not solved. My problem is Im using an special code in the links, like this: <a onclick="showPopup(21); return false;" href="#"> insert onclick is not suitable for the newest prestashop 1.5.5.0, when Im trying to save the product details I get the error "description field is not valid" Could anyone give me a little help please? Thank you Link to comment Share on other sites More sharing options...
vekia Posted September 30, 2013 Share Posted September 30, 2013 your problem is different, because you tried to add other code. follow this: http://mypresta.eu/en/art/developer/prestashop-product-page-full-rich-editor.html#validate_class_change 1 Link to comment Share on other sites More sharing options...
josias Posted September 30, 2013 Share Posted September 30, 2013 (edited) Thank you very much. Finally the solution was in override/classes/product.php my problems were with the module OpartAjaxPopup (for showing thickbox in product descriptions). the creator of the module sent me the file I mention before modified for ps. 1.5.5.0 Edited September 30, 2013 by josias (see edit history) Link to comment Share on other sites More sharing options...
somits1 Posted February 16, 2015 Share Posted February 16, 2015 I have little Query, Can any one help? I am using prestashop 1.56 English version. my site is http://slmobileprice.com I want to create a button on Product Description Page. I able to create button and share link on that button. But i want to create button like after clicking on button, link can open in new tab and display some popup with text or show text on previous page like "coupon". Thanks, Somit Srivastava Link to comment Share on other sites More sharing options...
bellini13 Posted February 16, 2015 Share Posted February 16, 2015 I have little Query, Can any one help? I am using prestashop 1.56 English version. my site is http://slmobileprice.com I want to create a button on Product Description Page. I able to create button and share link on that button. But i want to create button like after clicking on button, link can open in new tab and display some popup with text or show text on previous page like "coupon". Thanks, Somit Srivastava Why are you posting to a 2 year old solved topic that is completely unrelated to your question. Follow the forum rules and create a new topic Link to comment Share on other sites More sharing options...
somits1 Posted February 16, 2015 Share Posted February 16, 2015 if you think before 2 year problem is solve then tell me solution, before 2 year different version was running now different.. Link to comment Share on other sites More sharing options...
bellini13 Posted February 16, 2015 Share Posted February 16, 2015 no, how about you create a new topic for your new issue. this topic has nothing to do with what you are asking Link to comment Share on other sites More sharing options...
luchom Posted August 19, 2017 Share Posted August 19, 2017 (edited) hi i need your help i have this problem with order validation . every time i want to make a payment with bank-wire or check the system shows me error 500 i reinstalled the bank-kwire module, i have cleaned the cache ,activated the frame for hmtl,and always the same error.changed the permission on files to 755-777 and the same result. this is the url when error 500 appear :/index.php?fc=module&module=bankwire&controller=validation&id_lang=1 i checked the log file in local files and this is what a get {Property OrderDetail->product_ean13 is not valid at line 837 in file classes/ObjectModel.php i neeeeed help with this. prestashop 1.6.0.5 migration module (icg integration3.0) thnks Edited August 19, 2017 by luchom (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted August 20, 2017 Share Posted August 20, 2017 hi i need your help i have this problem with order validation . every time i want to make a payment with bank-wire or check the system shows me error 500 i reinstalled the bank-kwire module, i have cleaned the cache ,activated the frame for hmtl,and always the same error.changed the permission on files to 755-777 and the same result. this is the url when error 500 appear :/index.php?fc=module&module=bankwire&controller=validation&id_lang=1 i checked the log file in local files and this is what a get {Property OrderDetail->product_ean13 is not valid at line 837 in file classes/ObjectModel.php i neeeeed help with this. prestashop 1.6.0.5 migration module (icg integration3.0) thnks Validate that the "EAN-13 or JAN barcode" for the products in your order have a correct value.. 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