2

Could any1 please tell how this error can be solved?

I just have:

\Vendor\Module\Controller\Result\Index.php

<?php
namespace Vendor\Module\Controller\Result;

use Magento\Framework\App\Action\Context;

class Index extends \Magento\Framework\App\Action\Action
{
    protected $tglssearchHelper;
    protected $resultPageFactory;

    public function __construct(
        Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory

    )
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getLayout()->initMessages();
        $resultPage->getLayout()->getBlock('catalogsearch.leftnav');
        return $resultPage;
    }
}

My etc di:

<preference for="Magento\CatalogSearch\Controller\Result\Index" type="Vendor\Module\Controller\Result\Index" />

I get:

Fatal error: Cannot instantiate interface Magento\Catalog\Model\Layer\FilterableAttributeListInterface in C:\xampp\htdocs\magento2x_2\lib\internal\Magento\Framework\ObjectManager\Factory\Dynamic\Developer.php on line 73

2

There is example in Magento code of how to implements the filterable attribute list.

Basicaly it is a virtual type. In our ElasticSuite module we have this kind of things into the etc/frontend/di.xml :

    <virtualType name="searchFilterList" type="Smile\ElasticsuiteCatalog\Model\Layer\FilterList">
        <arguments>
            <argument name="filterableAttributes" xsi:type="object">Smile\ElasticsuiteCatalog\Model\Layer\Search\FilterableAttributeList</argument>
            <argument name="filters" xsi:type="array">
                <item name="attribute" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Attribute</item>
                <item name="price" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Price</item>
                <item name="decimal" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Decimal</item>
                <item name="category" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Category</item>
                <item name="boolean" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Boolean</item>
            </argument>
        </arguments>
    </virtualType>

Then it can be injected into the leftnav block :

<virtualType name="Magento\LayeredNavigation\Block\Navigation\Search" type="Smile\ElasticsuiteCatalog\Block\Navigation">
    <arguments>
        <argument name="filterList" xsi:type="object">searchFilterList</argument>
    </arguments>
</virtualType>

Maybe you will also have to fix some layout stuffs.

In my memory you have such an example in the Magento_CatalogSearch module.

You can also read the whole code in our ElasticSuite module : https://github.com/Smile-SA/elasticsuite/tree/master/src/module-elasticsuite-catalog

  • 1
    Thanks Aurelien Foucret, I added FilterableAttributeListInterface preference for FilterableAttributeList type, its working... – Sushivam Jul 13 '16 at 10:37

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.