I use echo in the class file in my extension.
Magento marketplace not allow echo/print_r/eval().
How to solve this problem ?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI use echo in the class file in my extension.
Magento marketplace not allow echo/print_r/eval().
How to solve this problem ?
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()
->createBlock('Vendor\Module\Block\Myclass')
->setTemplate('Vendor_Module::myfile.phtml')
->toHtml();
return $html;
}
check this file for more details:
https://github.com/mageprince/magento2-buynow/blob/master/Block/Product/ListProduct.php