im trying to separate the search query text from result.phtml and place it in its own template.

So basically ill have the product collection in results.phtml, and then the search query text "your search result no. products whatever" in searchtitle.phtml.

However im receiving Call to a member function getLoadedProductCollection() on boolean while trying to call the result.php functions from my own template file.

<move element="search.result" destination="main" />
<move element="sidebar.main" destination="page.top" />

<referenceContainer name="page.top" htmlTag="section" htmlClass="container-fluid w-100 p-0 bg-white">
    <block class="Magento\CatalogSearch\Block\Result" name="search.title" template="Magento_CatalogSearch::searchtitle.phtml" />


<?php if ($block->getResultCount()): ?>
    <h1 class="text-center">
        <?php echo 'We found ' . $block->getResultCount() . strstr($block->getSearchQueryText(), " ") ?>
 <?php endif; ?>

Im doing this as i want to move the search query text around the page in the layout, however, because the product collection and search query text are rendered in the same template file they're moving together and i want to place something between them, and unfortunately this cannot be called in the template file, so thats no a possibility.


Your Answer

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

Browse other questions tagged or ask your own question.