0

In 2.3.6, the following line was added to form.mini.phtml:

$configProvider = $block->getData('configProvider');

Since the upgrade, this returns null and causes a fatal error due to this subsequent call on the null object:

$configProvider->isSuggestionsAllowed()

"Uncaught Error: Call to a member function isSuggestionsAllowed() on null"

My site uses a custom module that adds notices during shipping and checkout using blocks. This module is causing the fatal error, but it shouldn't have anything to do with the search block.

I need to change the module di.xml file or custom class to return a configProvider for search, or tell it to use the default class. Can anyone point me the right direction? Many thanks.

Here is my code:

/app/code/Port80/CIBC/etc/frontend/di.xml


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Checkout\Model\CompositeConfigProvider">
        <arguments>
            <argument name="configProviders" xsi:type="array">
                <item name="cms_block_config_provider" xsi:type="object">Port80\CIBC\Model\ConfigProvider</item>
            </argument>
        </arguments>
    </type> 
    <preference for="Magento\Customer\Model\Vat" type="Port80\CIBC\Model\Customer\Vat" />
</config>

/app/code/Port80/CIBC/Model/ConfigProvider.php



use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\View\LayoutInterface;

class ConfigProvider implements ConfigProviderInterface
{
    /** @var LayoutInterface  */
    protected $_layout;

    public function __construct(LayoutInterface $layout)
    {
        $this->_layout = $layout;
    }

    public function getConfig()
    {
        return [
            'payment_notices' => $this->_layout->createBlock('Magento\Cms\Block\Block')->setBlockId('checkout_payment_notices')->toHtml(),
            'shipping_notices' => $this->_layout->createBlock('Magento\Cms\Block\Block')->setBlockId('checkout_shipping_notices')->toHtml()
        ];
    }
}
1

I had a similar problem after upgrading to 2.3.6. One of my theme layout files referred to the Magento_Search::form.mini.phtml template without the configProvider argument. adding the configProvider argument like this solved the issue:

<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml">
    <arguments>
        <argument name="configProvider" xsi:type="object">Magento\Search\ViewModel\ConfigProvider</argument>
    </arguments>
</block>
3
  • An additional note: The related "search_suggestion_enabled" config setting cannot be changed for the MySQL search provider in Magento CE, which means that search suggestions got disabled in my case... Solved by overriding the form.mini.phtml template from the Magento Search module – user9046547 Nov 21 '20 at 15:48
  • Thanks. I ended up overriding form.mini.phtml too. – mattf10 Nov 22 '20 at 16:04
  • where to add this lines ? – Rob D. A. Apr 1 at 18:59

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.