3

my etc/frontend/routes.xml is :

 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
    <route id="catalogsearch" frontName="catalogsearch">    <!--front name for the controller-->
        <module name="Tagalys_Tglssearch"/>
    </route>
  </router>
</config>

My controller paths are:

\Tagalys\Tglssearch\Controller\Catalog\Category.php

\Tagalys\Tglssearch\Controller\Catalog\CategoryController.php

\Tagalys\Tglssearch\Controller\CatalogSearch\Result.php

\Tagalys\Tglssearch\Controller\CatalogSearch\ResultController.php

is my layout file name correct ?

catalogsearch_result_index.xml

     <?xml version="1.0"?>
     <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <body>
    <referenceBlock name="catalogsearch.leftnav">
        <arguments>
            <argument name="setTemplate" xsi:type="string">Tagalys_Tglssearch::tagalys_search/filter.phtml</argument>
        </arguments>
    </referenceBlock>
  <referenceBlock name="product_searchlist_toolbar">
        <arguments>
            <argument name="template" xsi:type="string">Tagalys_Tglssearch::tagalys_toolbar/toolbar.phtml</argument>
        </arguments>
     </referenceBlock>
    </body>
  </page> 

Because my custom block is not at all getting called

class ListProduct extends \Magento\Catalog\Block\Product\ListProduct

public function __construct(
    /*passing all Constructors parameters to the parent class */    
    \Magento\Catalog\Block\Product\Context $context,
    \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
    \Magento\Catalog\Model\Layer\Resolver $layerResolver,
     CategoryRepositoryInterface $categoryRepository,
    \Magento\Framework\Url\Helper\Data $urlHelper,
    /*passing all Constructors parameters to the parent class */    

    \Tagalys\Tglssearch\Helper\Data $tglssearchHelper,
    \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $catalogResourceModelProductCollectionFactory,
    \Magento\Catalog\Model\Config $catalogConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    array $data = []
) {
    $this->tglssearchHelper = $tglssearchHelper;
    $this->catalogResourceModelProductCollectionFactory = $catalogResourceModelProductCollectionFactory;
    $this->catalogConfig = $catalogConfig;
    $this->storeManager = $storeManager;

      parent::__construct(
        $context,
        $postDataHelper,
        $layerResolver,
        $categoryRepository,
        $urlHelper,
        $data
    ); 
    //$this->tglssearchHelper = $tglssearchHelper;
}
protected function _getProductCollection()
{
         echo 'My block';
}
4
  • add complete catalogsearch_result_index.xml file for more debug Jun 23 '16 at 12:37
  • tats the completed code of the xml @Rakesh... wat did u ask?
    – Sushivam
    Jun 23 '16 at 12:44
  • you have to add whole file start with <?xml version="1.0"?> in above questions. Jun 23 '16 at 12:44
  • have updated @Rakesh
    – Sushivam
    Jun 23 '16 at 12:49
0

Your xml file is incorrect format, Your <page> node format is incorrect block with name product_searchlist_toolbar not available in magento 2. I have remove from below code, Remaining code are below you can set from below,

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="catalogsearch.leftnav">
        <arguments>
            <argument name="setTemplate" xsi:type="string">Tagalys_Tglssearch::tagalys_search/filter.phtml</argument>
        </arguments>
    </referenceBlock>

    </body>
  </page> 
10
  • and the remaining part of the block is it correct? and file name?
    – Sushivam
    Jun 23 '16 at 12:58
  • Remaining all is correct with filename Jun 23 '16 at 12:58
  • I have a doubt as to from where we use that 'index' from the layout file name...i was assuming 'routerfrontName_controllerActionName_controllerName'.xml... so it would be catalogsearch_catalogsearch_result.xml correct me if im wrong
    – Sushivam
    Jun 23 '16 at 13:04
  • Could you please explain the proper way of using, im still confused
    – Sushivam
    Jun 23 '16 at 13:04
  • catalogsearch_result_index.xml is the correct file, this file is used when search result is display in site. Jun 23 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.