1

I would like to override this quotation_quote_view.xml file layout (from a custom module) and add a block below this block reminder_date

<block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\ReminderDate" template="quote/view/reminderdate.phtml" name="reminder_date"/>

quotation_quote_view.xml

<?xml version="1.0"?><!--
~ Copyright (c) 2019. Cart2Quote B.V. All rights reserved.
~ See COPYING.txt for license details.
-->

<!--
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <link src="Cart2Quote_Quotation::js/bootstrap/quote-view-index.js"/>
    <css src="Cart2Quote_Quotation::css/styles.css"/>
</head>
<update handle="quotation_quote_view_item_price"/>
<update handle="quotation_quote_view_items"/>
<update handle="quotation_quote_view_load_block_totals"/>
<body>
    <!-- Move the quote items after search see handle: quotation_quote_view_items -->
    <move element="items" destination="data" after="search"/>
    <!-- Move the quote items after search see handle: quotation_quote_view_items -->
    <move element="totals" destination="data" after="reminder_date"/>
    <referenceContainer name="admin.scope.col.wrap" htmlClass="admin__old"/>
    <referenceBlock name="page.title">
        <action method="setTitleId">
            <argument translate="true" name="id" xsi:type="string">order-header</argument>
        </action>
    </referenceBlock>
    <referenceContainer name="js">
        <block class="Magento\Backend\Block\Template" template="Cart2Quote_Quotation::quote/view/js.phtml" name="view"/>
    </referenceContainer>
    <referenceContainer name="content">
        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View" name="quotation_quote_view"/>
        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\CustomProduct" template="Cart2Quote_Quotation::quote/create/customProductModal.phtml" name="custom_product_modal"/>
    </referenceContainer>
    <referenceContainer name="left">
        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Tabs" name="quotation_quote_tabs">
            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Tab\Info" name="quote_tab_info" template="quote/view/tab/info.phtml">
                <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Messages" name="message"/>
                <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Data" template="quote/view/data.phtml" name="data">
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\Sections" name="quote_sections" template="Cart2Quote_Quotation::quote/view/actions/sections.phtml"/>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Shipping\Method" template="quote/view/abstract.phtml" name="shipping_method">
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Shipping\Method\Form" template="quote/view/shipping/method/form.phtml" name="quote.view.shipping.method.form" as="form">
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Shipping\Method\Form\Quotation" template="quote/view/shipping/method/form/quotation.phtml" name="quote.view.shipping.method.form.quotation"/>
                        </block>
                    </block>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Search" template="quote/view/abstract.phtml" name="search">
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Search\Grid" name="search_grid" as="grid"/>
                    </block>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Data" template="quote/view/subtotalProposal.phtml" name="proposal"/>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_details" template="quote/view/details.phtml">
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Details\Account\Details" name="quote_details_account_details" template="quote/view/details/account/details.phtml">
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Details\Account\Details" name="quote_details_account_fields_customer_name" template="quote/view/details/account/fields/customerName.phtml"/>
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Details\Account\Details" name="quote_details_account_fields_email" template="quote/view/details/account/fields/email.phtml"/>
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Details\Account\Details" name="quote_details_account_fields_customer_group" template="quote/view/details/account/fields/customerGroup.phtml"/>
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Details\Account\Details" name="quote_details_account_fields_customer_account_data" template="quote/view/details/account/fields/customerAccountData.phtml"/>
                        </block>
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_details_quote_details" template="quote/view/details/quote/details.phtml">
                            <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\SelectRate" name="quote_details_quote_select_rate" template="quote/view/details/quote/selectRate.phtml"/>
                        </block>
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_details_order_details" template="quote/view/details/order/details.phtml"/>
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Comment" name="quote_details_quote_comment" template="quote/view/details/quote/comment.phtml"/>
                    </block>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_address" template="quote/view/address.phtml">
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_address_billing" template="quote/view/address/billing.phtml"/>
                        <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_address_shipping" template="quote/view/address/shipping.phtml"/>
                    </block>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\QuoteDate" template="quote/view/quotedate.phtml" name="quote_date"/>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\QuoteStatus" template="quote/view/quotestatus.phtml" name="quote_status"/>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\ExpiryDate" template="quote/view/expirydate.phtml" name="expiry_date"/>
                    <block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\ReminderDate" template="quote/view/reminderdate.phtml" name="reminder_date"/>
                    <block class="Magento\Framework\View\Element\Text\ListText" name="quote_item_extra_info"/>
                </block>
            </block>
            <action method="addTab">
                <argument name="name" xsi:type="string">quote_info</argument>
                <argument name="block" xsi:type="string">quote_tab_info</argument>
            </action>
        </block>
    </referenceContainer>
    <referenceContainer name="after.body.start">
        <block class="Magento\Catalog\Block\Adminhtml\Product\Composite\Configure" template="Magento_Catalog::catalog/product/composite/configure.phtml"/>
    </referenceContainer>
    <referenceBlock name="head.components">
        <block class="Magento\Framework\View\Element\Js\Components" name="quotation_page_head_components" template="Cart2Quote_Quotation::page/js/components.phtml"/>
    </referenceBlock>
</body>
</page>

So I created a module and a layout file under Vendor/Module/view/adminhtml/layout/quotation_quote_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="data">

        <block class="Vendor\Module\Block\Adminhtml\Quote\View\DailyCron" after="reminder_date" name="quote_daily_cron" template="quote/daily_cron.phtml"/>

    </referenceContainer>
</body>
</page>

In view/adminhtml/templates/quote/daily_cron.phtml

<?php
$quote = $block->getQuote();

?>
<div class="admin__field field-comment ">
<th>
    <label for="quote-reminder-date" class="admin__field-label">
        <span><?php echo $block->escapeHtml(__('Daily reminder')) ?></span>
    </label>
</th>
<td>
    <div class="admin__field-control">


    </div>
</td>
</div>

But this doesn't work, so how to override a layout and add a block after a given block?

2 Answers 2

1

Inside module.xml file, you have to declare dependency of core module,

<?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="Vendor_Modulename" setup_version="1.0.0" active="true">
        <sequence>
            <module name="Magento_Sales"/>
        </sequence>
    </module>
</config>

Change the module Magento_Sales whatever you want to override this layout..

You have to first check if any log error are generated for this layout.

You have to just clear cache and remove var folder.

3
  • I'm trying to override a custom module Cart2Quote i've already put this code in module.xml <module name="Wetag_DailyCron" setup_version="1.0.0"> <sequence> <module name="Cart2Quote_Quotation"/> </sequence> </module> Aug 8, 2019 at 12:54
  • You have to just clear cache and remove var folder.
    – aissyass
    Aug 8, 2019 at 12:57
  • Please check your layout file path like this: app/code/Wetag/DailyCron/view/adminhtml/layout/quotation_quote_view.xml
    – aissyass
    Aug 8, 2019 at 13:01
0

Step 1: Inside quotation_quote_view.xml file, you have to override the the details block.

<block class="Cart2Quote\Quotation\Block\Adminhtml\Quote\View\Info" name="quote_details_quote_details" template="Vendor_Cart2QuoteQuotation::quote/view/details/quote/details.phtml">

Step 2: Inside the details.phtml line 56, add the html block.

<?php echo $block->getBlockHtml('quote_daily_cron') ?>
    

Step 3: Clear cache

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.