1

I need to override the third party module template file app/code/Codazon/Shopbybrandpro/view/frontend/templates/brand/brand_search.phtml

Relevant Block from Original

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Codazon\Shopbybrandpro\Block\Brand\AllBrands" name="all_brands" template="Codazon_Shopbybrandpro::brand/all_brands.phtml">
                <block class="Codazon\Shopbybrandpro\Block\Widget\BrandSearch" name="brand_search" template="Codazon_Shopbybrandpro::brand/brand_search.phtml" />
                <block class="Codazon\Shopbybrandpro\Block\Widget\BrandSlider" name="featured_brands" template="Codazon_Shopbybrandpro::brand/featured_brands.phtml" />
                <block class="Codazon\Shopbybrandpro\Block\Brand\AllBrands" name="brand_alphabet_list" template="Codazon_Shopbybrandpro::brand/list-container.phtml">
                    <block class="Codazon\Shopbybrandpro\Block\Brand\BrandList" name="brand_list" template="Codazon_Shopbybrandpro::brand/list.phtml">
                        <block class="Codazon\Shopbybrandpro\Block\Brand\BrandList\Toolbar" name="brand_list_toolbar" template="Codazon_Shopbybrandpro::brand/list/toolbar.phtml">
                            <block class="Magento\Theme\Block\Html\Pager" name="brand_list_toolbar_pager"/>
                        </block>
                        <action method="setToolbarBlockName">
                            <argument name="name" xsi:type="string">brand_list_toolbar</argument>
                        </action>
                    </block>
                </block>
            </block>
        </referenceContainer>
    </body>
</page>

Please see the 2nd block brand_search

I tried to override brand/brand_search.phtml like in the following.

In my module, view/frontend/layout/default.xml

<?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">
<body>
    <referenceBlock name="brand_search" template="Iwdat_UiCustom9::brand_search.phtml"/>            
</body>
</page>

And I have a modified copy of original phtml file view/frontend/templates/brand_search.phtml

Even after compiling,removal of cache and static content still the modifications are not reflected in froned.

Have I done any syntactical error or other could this be another issue.

Thanks and Best Regards

Indunil

3
  • Can you please share the name of vendor XML file where the template path is defined for block brand_search.phtml Oct 27, 2022 at 4:11
  • Hi, Thanks for the reply. it is view/frontend/layout/brands_index_index.xml Oct 27, 2022 at 4:15
  • Please try below code Oct 27, 2022 at 4:23

3 Answers 3

1

Please extend the file in design folder following the below path

Codazon_Shopbybrandpro/templates/brand/brand_search.phtml

0

Update your default.xml with below code

<?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">
   <body>
    <referenceContainer name="content">
        <referenceBlock name="brand_search" template="Iwdat_UiCustom9::brand_search.phtml"/>            
    </referenceContainer>
   </body>
</page>

Flush cache and check in frontend

Let me know if you find any issue

Thanks

0

Extend like this: Codazon_Shopbybrandpro create this at app/code/design/vendor/theme/Codazon_Shopbybrandpro/templates/brand/brand_search.phtml

in your xml e.g default.xml add this:

<?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">
    <body>
        <referenceBlock name="brand_search" template="Codazon_Shopbybrandpro::brand/brand_search.phtml"/>            
    </body>
</page>

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.