How to extend the block file functionality?
Because the search popular terms page shows as empty, so I have extended the block file as the following. But it is not working.
/app/code/Talk/CustomSearch/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'CustomSearch',
__DIR__
);
/app/code/Talk/CustomSearch/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="CustomSearch" setup_version="1.0.0">
</module>
</config>
/app/code/Talk/CustomSearch/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Search\Block\Term" type="Talk\CustomSearch\Block\Term" />
</config>
/app/code/Talk/CustomSearch/Block/Term.php
<?php
/**
* Search term block
*/
namespace Talk\CustomSearch\Block;
class Term extends \Magento\Search\Block\Term
{
/**
* Load terms and try to sort it by names
*
* @return $this
*/
protected function _loadTerms()
{
exit('LoadTerms');
}
}
The function _loadTerms() is not called. How to extend the block in the magento-search module?