I use echo in the class file in my extension.

Magento marketplace not allow echo/print_r/eval().

How to solve this problem ?

  • Someone suggested me that never echo always return and use log to check the dumpy data.
    – inrsaurabh
    Mar 6 '18 at 11:38
  • 1
    Ok, but I use observer and helper and I use an echo in helper file as per my requirement. Any solution ? @SaurabhRanjan Mar 6 '18 at 11:41
  • 1
    Plz follow what @prince sir suggested
    – inrsaurabh
    Mar 6 '18 at 12:30

As per Coding Standard, you should not use echo in block, helper, Model .. etc. Instead of you can create phtml file with your content. And call it in observer like:

public function getProductDetailsHtml(\Magento\Catalog\Model\Product $product)
    $html = $this->getLayout()

    return $html;

check this file for more details:


  • Thank you @prince Patel. This is very useful for me. Till now it is not work in layered navigation. I will try, if not get any solution than ping you. Mar 7 '18 at 9:22

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.