bissio Posted April 28, 2017 Share Posted April 28, 2017 Hi guys,first of all these are my settings: PHP 5.4.45 - PS 1.7.1.1 (latest stable) - Mysql 5.5.50I installed the latest release of PS and all works fine except on the products section. When i try to insert a new product and set title and i try to insert an image, the (enabling the debug mode) i get the error reported on the attached file. Also, on my apache error log i get the following: PHP Fatal error: Call to a member function trans() on a non-object in /mysite_root/classes/controller/AdminController.php on line 2735 and this is the interested funcion:public function l($string, $class = null, $addslashes = false, $htmlentities = true) { $translated = $this->translator->trans($string); if ($translated !== $string) { return $translated; } if ($class === null || $class == 'AdminTab') { $class = substr(get_class($this), 0, -10); } elseif (strtolower(substr($class, -10)) == 'controller') { /* classname has changed, from AdminXXX to AdminXXXController, so we remove 10 characters and we keep same keys */ $class = substr($class, 0, -10); } return Translate::getAdminTranslation($string, $class, $addslashes, $htmlentities); }I also tried to import some products by CSV file but i get the same errors.It seems a symfony issue but the error is related to a PHP controller core file.i Checked on all forums but i did not find anything about this issue. Can someone help me?Thanks Link to comment Share on other sites More sharing options...
Flávio's Posted May 3, 2017 Share Posted May 3, 2017 Hi bissio, I found the solution here https://www.h-hennes.fr/blog/2017/04/11/prestashop-1-7-correction-bug-traduction-dans-controller-admin-dun-module/ I just edited the line $translated = $this->translator->trans($string); to $translated = Context::getContext()->getTranslator()->trans($string); and all works fine, I hope it help you! 3 Link to comment Share on other sites More sharing options...
bissio Posted May 3, 2017 Author Share Posted May 3, 2017 Hi Flavio and thank you for you help. in the meantime i solved reinstalling a new new and blank version of PS 1.7.1... it was a strange behaviour because with the same environment, into the new version i did not get this error.. even importin a lot of items by CSV, or inserting them one by one. I translated meny CSM pages and modules as well but at the moment i did not get this annoying error... However i will keep in my box your suggestion so if i should get this error again, i will try to apply it.Thanks again ;-) Link to comment Share on other sites More sharing options...
Zohaib-fk Posted October 2, 2017 Share Posted October 2, 2017 Hi, I tried to put function in my file but still getting error message so I tried below solution and it works for me. I replace code $this->l with $this->trans and it works fine. Link to comment Share on other sites More sharing options...
eridamega Posted March 4, 2018 Share Posted March 4, 2018 On 3/5/2017 at 6:51 AM, Flávio's said: Hi bissio, I found the solution here https://www.h-hennes.fr/blog/2017/04/11/prestashop-1-7-correction-bug-traduction-dans-controller-admin-dun-module/ I just edited the line $translated = $this->translator->trans($string); to $translated = Context::getContext()->getTranslator()->trans($string); and all works fine, I hope it help you! I do what you say. and it works fine but when I go to confirm the payment (the last step) it shows nothing. should show the order confirmation page but nothing comes out this is the result link www.mynamestore.com/module/universalpay/payment?id_universalpay_system=2 why?? Thanks Link to comment Share on other sites More sharing options...
musicmaster Posted March 4, 2018 Share Posted March 4, 2018 Most likely you have some php error. Enable development mode to see what it is: https://www.prestashop.com/forums/topic/224525-how-to-turn-on-error-reporting-for-debug-information-blank-page-500-internal-server-error/ Link to comment Share on other sites More sharing options...
eridamega Posted March 4, 2018 Share Posted March 4, 2018 1 hour ago, musicmaster said: Most likely you have some php error. Enable development mode to see what it is: https://www.prestashop.com/forums/topic/224525-how-to-turn-on-error-reporting-for-debug-information-blank-page-500-internal-server-error/ Thanks for answering After Changing $translated = $this->translator->trans($string); to $translated = Context::getContext()->getTranslator()->trans($string); I get this in the final step (when confirming the order) [PrestaShopException] No template found for payment_execution.tplat line 68 in file classes/Smarty/TemplateFinder.php 63. return $tpl; 64. } 65. } 66. } 67. 68. throw new PrestaShopException('No template found for '.$template); 69. } 70. 71. private function getTemplateHierarchy($template, $entity, $id) 72. { 73. $entity = basename($entity); TemplateFinderCore->getTemplate - [line 1392 - classes/controller/FrontController.php] - [4 Arguments] 1387. return $this->getTemplateFinder()->getTemplate( 1388. $template, 1389. $params['entity'], 1390. $params['id'], 1391. $locale 1392. ); 1393. } 1394. 1395. /** 1396. * Renders and adds color list HTML for each product in a list. 1397. * FrontControllerCore->getTemplateFile - [line 1282 - classes/controller/FrontController.php] - [3 Arguments] 1277. * @param string $default_template 1278. */ 1279. public function setTemplate($template, $params = array(), $locale = null) 1280. { 1281. parent::setTemplate( 1282. $this->getTemplateFile($template, $params, $locale) 1283. ); 1284. } 1285. 1286. /** 1287. * Removed in PrestaShop 1.7. FrontControllerCore->setTemplate - [line 61 - classes/controller/ModuleFrontController.php] - [3 Arguments] 56. public function setTemplate($template, $params = array(), $locale = null) 57. { 58. if (strpos($template, 'module:') === 0) { 59. $this->template = $template; 60. } else { 61. parent::setTemplate($template, $params, $locale); 62. } 63. } 64. 65. public function initContent() 66. { ModuleFrontControllerCore->setTemplate - [line 54 - modules/universalpay/controllers/front/payment.php] - [1 Arguments] 49. 'this_path' => $this->module->getPathUri(), 50. 'this_path_ssl' => Tools::getShopDomainSsl(true, 51. true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/' 52. )); 53. 54. $this->setTemplate('payment_execution.tpl'); 55. } 56. } UniversalPaypaymentModuleFrontController->initContent - [line 205 - classes/controller/Controller.php] 200. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) { 201. $this->initHeader(); 202. } 203. 204. if ($this->viewAccess()) { 205. $this->initContent(); 206. } else { 207. $this->errors[] = $this->trans('Access denied.', array(), 'Admin.Notifications.Error'); 208. } 209. 210. if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className))) { ControllerCore->run - [line 428 - classes/Dispatcher.php] 423. if (isset($params_hook_action_dispatcher)) { 424. Hook::exec('actionDispatcher', $params_hook_action_dispatcher); 425. } 426. 427. // Running controller 428. $controller->run(); 429. 430. // Execute hook dispatcher after 431. if (isset($params_hook_action_dispatcher)) { 432. Hook::exec('actionDispatcherAfter', $params_hook_action_dispatcher); 433. } DispatcherCore->dispatch - [line 28 - index.php] 23. * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) 24. * International Registered Trademark & Property of PrestaShop SA 25. */ 26. 27. require(dirname(__FILE__).'/config/config.inc.php'); 28. Dispatcher::getInstance()->dispatch(); Link to comment Share on other sites More sharing options...
musicmaster Posted March 4, 2018 Share Posted March 4, 2018 Quote No template found for payment_execution.tpl Did you check whether the file is there? Maybe it went missing and you need to copy it from a backup. 1 Link to comment Share on other sites More sharing options...
eridamega Posted March 4, 2018 Share Posted March 4, 2018 27 minutes ago, musicmaster said: Did you check whether the file is there? Maybe it went missing and you need to copy it from a backup. I have the file payment_execution.tpl and it has the same content as this https://github.com/prestalab/universalpay/blob/ps17/views/templates/front/payment_execution.tpl Link to comment Share on other sites More sharing options...
musicmaster Posted March 4, 2018 Share Posted March 4, 2018 The big question is whether it is in the same directory as where Smarty looks for it. Link to comment Share on other sites More sharing options...
eridamega Posted March 4, 2018 Share Posted March 4, 2018 50 minutes ago, musicmaster said: The big question is whether it is in the same directory as where Smarty looks for it. Excuse my ignorance and insistence. In what directory does that seek or should it be? I know little or nothing about the subject, Thank you in advance for your patience Link to comment Share on other sites More sharing options...
musicmaster Posted March 4, 2018 Share Posted March 4, 2018 I don't know either. The minimum what you could do is provide me with all the information that you can find - and to be creative looking for it. Maybe that will bring up something interesting. Link to comment Share on other sites More sharing options...
eridamega Posted March 4, 2018 Share Posted March 4, 2018 (edited) 5 hours ago, musicmaster said: I don't know either. The minimum what you could do is provide me with all the information that you can find - and to be creative looking for it. Maybe that will bring up something interesting. Hi @musicmaster, I use PS 1.7.3.0 and installed UniversalPay V3.0.0. First when I click on Pay Systems tab I get error 500, this is PHP error: Fatal error: Call to a member function trans () on null in ...... / classes / controller / AdminController.php on line 2754 Then I made a change in .../classes/controller/AdminController.php edited the line $translated = $this->translator->trans($string); to $ translated = Context :: getContext () -> getTranslator () -> trans ($ string); As the message said back and error 500 was solved. Add two Payment Methods for testing and I proceed to make a purchase, when I am in the final step just when It should show the confirmation of the purchase I see another error and it does does not show me the order confirmation. This error appears (this https://www.prestashop.com/forums/topic/607468-call-to-a-member-function-trans-on-a-non-object/?tab=comments#comment-2699736 ) this is the content of the folder ../modules/universalpay/views/templates/front this is the content of the folder ../modules/universalpay/views/templates/hook Please if you need more info thanks Edited March 4, 2018 by eridamega (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted March 4, 2018 Share Posted March 4, 2018 1.7.3: that is the bleeding is edge. Problem with being so up-to-date is that you never can be sure that your modules are compatible with it. So i suggest that you build a test installation on your localhost - with PS 1.7.3 but the default template - where you test each of your special modules. The error "Call to a member function trans() on a non-object" that you mention once again should by now be solvable. Just find out where it happens and apply the lessons from this thread. Link to comment Share on other sites More sharing options...
Portofel Posted June 24, 2020 Share Posted June 24, 2020 On 5/3/2017 at 1:51 PM, Flávio's said: Hi bissio, I found the solution here https://www.h-hennes.fr/blog/2017/04/11/prestashop-1-7-correction-bug-traduction-dans-controller-admin-dun-module/ I just edited the line $translated = $this->translator->trans($string); to $translated = Context::getContext()->getTranslator()->trans($string); and all works fine, I hope it help you! Thank you Flávio's, works very well, have this error with the pcbuilder module, php 7.0.33 Many thanks Link to comment Share on other sites More sharing options...
Alexander Firsov Posted July 31, 2022 Share Posted July 31, 2022 On 5/3/2017 at 6:51 PM, Flávio's said: I found the solution here https://www.h-hennes.fr/blog/2017/04/11/prestashop-1-7-correction-bug-traduction-dans-controller-admin-dun-module/ I just edited the line $translated = $this->translator->trans($string); Thank you. It worked for me in Prestashop v1.7.7.1 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