How is this layout file named , i mean on what basis. (Since there is no controller and router xml)


If im correct, it references the Catalog modules Controller Category path.

But from where is : "view_type_layered" in the layout file name coming from?

What i want to achieve: when we click on one of the filters the file which is responsible for the results is state.phtml . My custom filters on click are not filtering the results.

UPDATE My current overridden layout file (catalogsearch_result_index) is for view:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock class="Vendor\LayeredNavigation\Block\Navigation" before="-" name="catalogsearch.leftnav">
      <action method="setTemplate">
        <argument name="template" xsi:type="string">Vendor_LayeredNavigation::layer/view.phtml</argument>

    <referenceBlock class="Magento\LayeredNavigation\Block\Navigation\State" before="-" name="catalogsearch.navigation.state" as="state">
      <action method="setTemplate">
        <argument name="template" xsi:type="string">Vendor_LayeredNavigation::layer/state.phtml</argument>

1) Should i override state.phtml too?

2) If so, what is the layout file name: is it catalog_category_view_type_layered or catalogsearch_result_index itself.

1 Answer 1


The catalog_category_view_type_layered layout handle is added via Magento/Catalog/Controller/Category/View.php in the execute() method:

$hasChildren = $category->hasChildren();
if ($category->getIsAnchor()) {
    $type = $hasChildren ? 'layered' : 'layered_without_children';
} else {
    $type = $hasChildren ? 'default' : 'default_without_children';

if (!$hasChildren) {
    // Two levels removed from parent.  Need to add default page type.
    $parentType = strtok($type, '_');
    $page->addPageLayoutHandles(['type' => $parentType]);
$page->addPageLayoutHandles(['type' => $type, 'id' => $category->getId()]);

The addPageLayoutHandles method from Magento/Framework/View/Result/Page automatically generates the handle base on the default handle catalog_category_view, the key of the array type and the value layered.

Regarding your other question it totally depends on what you want to achieve:

  • If you want to override the filters on the category layered page you need to use catalog_category_view_type_layered.xml
  • If you want to override the filters on the search page you need to use catalogsearch_result_index .xml
  • If you need to override both pages, you need both files
  • ok Raphael, i am overriding filters on search page,and my current layout file is correct and i get custom filters too, but, my filters dont seem to be applied on selecting one... do i need state.phtml (in my code above, state phtml doesnt seem to be called at all) or whats wrong?
    – Sushivam
    Oct 6, 2016 at 10:55
  • @SachinS well it's hard to say without looking at the code. I reckon you should create a new question and avoid posting several questions in one post Oct 6, 2016 at 10:57
  • Could you pls tell which part of my code needs to be checked, so that i can post...related to filters not getting affected
    – Sushivam
    Oct 6, 2016 at 10:58
  • @SachinS well the part that overrides the filters Oct 6, 2016 at 11:04
  • I have asked a new question here magento.stackexchange.com/questions/139669/… @Raphael..
    – Sushivam
    Oct 6, 2016 at 11:22

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.