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
    Commented Mar 6, 2018 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 Commented Mar 6, 2018 at 11:41
  • 1
    Plz follow what @prince sir suggested
    – inrsaurabh
    Commented Mar 6, 2018 at 12:30

1 Answer 1


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. Commented Mar 7, 2018 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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