I am trying to override /module-sales/view/frontend/templates/order/view.phtml by di.xml
<preference for="Magento\Sales\Block\Order\View" type="Myvendor\Mymodule\Block\Order\View"/>
The Block i added is
namespace Myvendor\Mymodule\Block\Order;
use Magento\Customer\Model\Context;
/**
* Sales order view block
*/
class View extends \Magento\Sales\Block\Order\View
{
/**
* @var string
*/
protected $_template = 'corder/view.phtml';
This is working fine , but i want to load my Phtml file when my module is enabled.
I tried
- If condition in phtml file looks bad.
- No way to add ifConfig in layout ( There is no layout in my module ).
- beforeToHtml function in block ( Not working ).
- setTemplate function in block ( Not working ).
Any Help would be appreciated.