0

I have a third party module, and I'm trying to override the third party .phtml file but it's not working for me. For these, I tried below ways.

Third-Party Layout module:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="quotation_item_price_renderers"/>
    <body>
          <referenceBlock name="quotation.quote.item.renderers">
               <block class="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer" as="default" template="Magebees_QuotationManager::quote/item/default.phtml">
                    <block class="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer\Actions" name="quotation.quote.item.renderers.default.actions" as="actions">
                        <block class="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer\Actions\Edit" name="quotation.quote.item.renderers.default.actions.edit" template="Magebees_QuotationManager::quote/item/edit.phtml"/>
                        <block class="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer\Actions\Remove" name="quotation.quote.item.renderers.default.actions.remove" template="Magebees_QuotationManager::quote/item/remove.phtml"/>
                    </block>
                </block>         
        </referenceBlock> 
    </body>
</page>

Now I want to Override quote/item/default.phtml file.

I tried 2 Ways.

1) Extended luma theme

Copied default.phtml file and pasted in design/frontend/Magento/luma/Magebees_QuotationManager/templates/quote/item/default.phtml

After the above step I executed the upgrade, compile, static-content: deploy commands, still not working.

2) Tried with di.xml

created di.xml in etc/frontend/di.xml and written below code.

<?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="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer"  type="ABCSolutions\CQWCProduct\Block\Checkout\Cart\Item\Renderer" />
</config>

And I set the template in the Block file see below code.

<?php

namespace ABCSolutions\CQWCProduct\Block\Checkout\Cart\Item;

use Magebees\QuotationManager\Helper\Quotation;
use Magebees\QuotationManager\Model\QuoteFactory;
use Magento\Catalog\Block\Product\ImageBuilder;
use Magento\Catalog\Helper\Product\Configuration;
use Magento\Checkout\Model\Session;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Module\Manager;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Url\Helper\Data;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
use Magento\Framework\View\Element\Template\Context;

class Renderer extends \Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer{


    public function __construct(
        Context $context,
        Configuration $qproductConfig,
        Quotation $quoteHelper,
        Session $checkoutSession,
        ImageBuilder $imageBuilder,
        Data $urlHelper,
        ManagerInterface $qmessageManager,
        PriceCurrencyInterface $priceCurrency,
        Manager $moduleManager,
        InterpretationStrategyInterface $qmessageInterpretationStrategy,
        QuoteFactory $quoteFactory,
        array $data = []
    ){
        parent::__construct($context, $qproductConfig, $quoteHelper, $checkoutSession, $imageBuilder, $urlHelper, $qmessageManager, $priceCurrency, $moduleManager,
            $qmessageInterpretationStrategy, $quoteFactory, $data);
        $this->setTemplate("ABCSolutions_CQWCProduct::quote/item/default.phtml");
    }

}

In default.phtml file pasted the code from the Magebees module & added extra content with "Extended".

Still not getting the updated design.

Please suggest me if I went wrong?

10
  • Did you give sequence in your module.xml file? Nov 6, 2019 at 7:28
  • @RohanHapani Yes, given.
    – Bojjaiah
    Nov 6, 2019 at 7:31
  • @RohanHapani, I have given ` <module name="ABCSolutions_CQWCProduct" setup_version="0.1.1" /> <sequence> <module name="Magento_Sales"/> <module name="Magento_Catalog"/> <module name="Magebees_QuotationManager"/> </sequence>`
    – Bojjaiah
    Nov 6, 2019 at 7:32
  • Did you upgrade your module after add sequence? Nov 6, 2019 at 7:33
  • @RohanHapani, Yes, Executed the upgrade, compile & static-content:deploy commands. still not working
    – Bojjaiah
    Nov 6, 2019 at 7:36

3 Answers 3

0

It seems like your syntax issue in your module.xml :

Your code :

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
   <module name="ABCSolutions_CQWCProduct" setup_version="0.1.1" />
   <sequence>
      <module name="Magento_Sales"/>
      <module name="Magento_Catalog"/>
      <module name="Magebees_QuotationManager"/>
   </sequence>
</config>

Replace with this below code :

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
   <module name="ABCSolutions_CQWCProduct" setup_version="0.1.1">
       <sequence>
          <module name="Magento_Sales"/>
          <module name="Magento_Catalog"/>
          <module name="Magebees_QuotationManager"/>
       </sequence>
    </module>
</config>

Then, do upgrade process.

3
  • 1
    Thank you for the suggestion, Let's try and coma back.
    – Bojjaiah
    Nov 6, 2019 at 9:05
  • Still, not working bro.
    – Bojjaiah
    Nov 6, 2019 at 9:36
  • Oh..!! Strange..!! It should be working now. Nov 6, 2019 at 9:37
0
<?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">
   <update handle="quotation_item_price_renderers"/>
    <body>
       <referenceBlock name="default">
            <arguments>
                <argument name="template" xsi:type="string">Vendor_Module::quote/item/default.phtml</argument>
            </arguments>
       </referenceBlock>
    </body>
</page>

OR

<referenceBlock name="default" template="Vendor_Module::quote/item/default.phtml"/>
7
  • Thank you for the answer. Let's try and come back
    – Bojjaiah
    Nov 6, 2019 at 9:04
  • I have tried the above 2 methods in my module quotation.quote.item.renderers.xml layout file, but not working for me. I'm I fallowed correct or wrong? please suggest.
    – Bojjaiah
    Nov 6, 2019 at 9:43
  • 1
    what is your xml file name? quotation.quote.item.renderers.xml or quotation_quote_item_renderers.xml Nov 6, 2019 at 9:45
  • The layout file name is quotation_quote_item_renderers.xml.
    – Bojjaiah
    Nov 6, 2019 at 9:46
  • Understood, wait a minute will try again.
    – Bojjaiah
    Nov 6, 2019 at 9:48
0

Finally, solved my self by using the 2nd Method in my thread.

di.xml file

<?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="Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer"   type="ABCSolutions\CQWCProduct\Block\Checkout\Cart\Item\Renderer"/>

</config>

Renderer.php file

<?php

namespace ABCSolutions\CQWCProduct\Block\Checkout\Cart\Item;

use Magebees\QuotationManager\Helper\Quotation;
use Magebees\QuotationManager\Model\QuoteFactory;
use Magento\Catalog\Block\Product\ImageBuilder;
use Magento\Catalog\Helper\Product\Configuration;
use Magento\Checkout\Model\Session;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Module\Manager;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Url\Helper\Data;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
use Magento\Framework\View\Element\Template\Context;
use \Magebees\QuotationManager\Model\QuoteFilesFactory;

class Renderer extends \Magebees\QuotationManager\Block\Checkout\Cart\Item\Renderer{


    /**
     * @var QuoteFilesFactory
     */
    protected $_quoteFilesFactory;


    public function __construct(
        Context $context,
        Configuration $qproductConfig,
        Quotation $quoteHelper,
        Session $checkoutSession,
        ImageBuilder $imageBuilder,
        Data $urlHelper,
        ManagerInterface $qmessageManager,
        PriceCurrencyInterface $priceCurrency,
        Manager $moduleManager,
        InterpretationStrategyInterface $qmessageInterpretationStrategy,
        QuoteFactory $quoteFactory,
        QuoteFilesFactory $quoteFilesFactory,
        array $data = []
    ){
        parent::__construct($context, $qproductConfig, $quoteHelper, $checkoutSession, $imageBuilder, $urlHelper, $qmessageManager, $priceCurrency, $moduleManager,
            $qmessageInterpretationStrategy, $quoteFactory, $data);
        $this->_quoteFilesFactory = $quoteFilesFactory;
        $this->setTemplate("ABCSolutions_CQWCProduct::quote/item/default.phtml");
    }

    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $this->setTemplate("ABCSolutions_CQWCProduct::quote/item/default.phtml");
        return $this;
    } 

}

default.phtml file

added "Extended" content.

1
  • just wondering was this layout handle added dynamically from Magebees module with: $resultPage->addHandle('new_layout_handle'); type code? I'm having similar issues it seems like these handles when added that way do not check for the corresponding layout in other modules besides itself, maybe is a Magento 2 bug? Nov 2, 2020 at 5:32

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.