0

I am going through an older module created in PHP 5.x.x and we have just moved the website to the php 7.2.x so we suddenly got the error in a helper class

Uncaught Error: Using $this when not in object context in

There is a dispatch event in helper that is using the following code there:

Mage::dispatchEvent('magento_string_filter_before', array('content' => $contentObj, 'object' => $params['object'], 'params' => $params, 'helper' => $this));

and i believe that is not compatible with the PHP 7 so how i can convert this and what replacement we have?

Thanks!

  • Are you trying to pass the object of current helper, right? – Dhiren Vasoya Aug 7 at 6:19
  • Yes you are right! – shoaib Munir Aug 7 at 12:59
  • You need to replace $this with your helper class. – Dhiren Vasoya Aug 8 at 9:30
0

I have pass the object of the helper as like

replacing $this with following:

Mage::getSingleton('my_helper_here');

and code looks like this now and working fine for.

Mage::dispatchEvent('magento_string_filter_after', array('content' => $contentObj, 'object' => $params['object'], 'params' => $params, 'helper' => Mage::getSingleton('my_helper_here')));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.