It seems to be impossible to override the template vendor\magento\module-checkout\view\frontend\templates\cart\item\renderer\actions\edit.phtml from your own module e.g. by using layout updates.
(The template shows the edit button near quote items in the cart)
Preconditions:
Magento 2.3.5-p2
Steps to reproduce:
Create own module (In my case: Company_Configurator)
Create Template file: app\code\Company\Configurator\view\frontend\templates\cart\item\renderer\actions\edit.phtml and change content.
Create layout update file app\code\Company\Configurator\view\frontend\layout\checkout_cart_item_renderers.xml with following content:
<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.cart.item.renderers.simple.actions.edit"> <arguments> <argument name="template" xsi:type="string">Company_Configurator::cart/item/renderer/actions/edit.phtml</argument> </arguments> </referenceBlock> </body> </page>
Attempt 2:
I even tried to extend the block class, override it with dependency injection and then set the template:
app/code/Company/Configurator/etc/frontend/di.xml:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" type="Company\Configurator\Block\Cart\Item\Renderer\Actions\Edit" /> </config>
app\code\Company\Configurator\Block\Cart\Item\Renderer\Actions\Edit.php
namespace Company\Configurator\Block\Cart\Item\Renderer\Actions;
class Edit extends \Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit
{
protected $_template = 'Company_Configurator::cart/item/renderer/actions/edit.phtml';
function __construct(\Magento\Framework\View\Element\Template\Context $context, array $data = [])
{
parent::__construct($context, $data);
}
...
}
Expected result:
Template should get changed to own template.
Actual result:
Old template is still loading.
Please Help