I need to override the phtml template using my custom theme.

1) I need to override the toolbar.phtml from Catalog module except that i need to use my toolbar.phtml which is placed in my custom theme.

2) If we use this method, is there a need to use the layout xml files? If so how to override the same.

Need example for both!


1 Answer 1


You only need to use one method.

1. Override template file

Copy the file from: vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar.phtml

To your theme: app/design/frontend/<vendor>/<theme>/Magento_Catalog/templates/product/list/toolbar.phtml

Make your changes in the new file.

2. Load new template file via xml

As an example using the category view:

Extend the parent catalog_category_view.xml file by creating: app/design/frontend/<vendor>/<theme>/Magento_Catalog/layout/catalog_category_view.xml

In the body section update the template of the product_list_toolbar block with:

<referenceBlock name="product_list_toolbar" template="Magento_Theme::html/new-toolbar.phtml"/>

The example path of the template file corresponds to: app/design/frontend/<vendor>/<theme>/Magento_Theme/templates/html/new-toolbar.phtml

  • Hi Oscarpas, do you mean , vendor/magento as app/code/Magento/Catalog/... cause i dont have vendor/magento/module-catalog/view/ ..I have installed Magento using composer github...I have vendor/magento/composer
    – Sushivam
    Aug 22, 2016 at 5:10
  • If its not in vendor/Magento it should be in app/design/frontend/Magento. You can turn on template hints to make sure.
    – oscarpas
    Aug 22, 2016 at 7:09
  • Ok for eg i f i want to get the pagination in my products page from my custom theme..can u pls show an eg for the same?
    – Sushivam
    Aug 22, 2016 at 7:11
  • Turn on template hints to find the correct .phtml file. Use the instructions in my answer.
    – oscarpas
    Aug 22, 2016 at 8:21
  • Hi @Oscarpas, could you please help me in this error for overriding my custom layout file.. I have followed the same step as mentioned ...magento.stackexchange.com/questions/133188/…
    – Sushivam
    Aug 26, 2016 at 9:24

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.