0

If one goes by the traditional Magento methodology to repeat a class in layout files, then the following should work:

Magento Example in Catalog:

<block class="Magento\Catalog\Block\Category\View" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="Magento\Catalog\Block\Category\View" name="category.description" template="Magento_Catalog::category/description.phtml"/>

So I want to create a new file in Catalog Search

<block class="Magento\CatalogSearch\Block\Result" name="search.result" template="Magento_CatalogSearch::result.phtml" cacheable="false">
<!-- ^ Magento default -->
<block class="Magento\CatalogSearch\Block\Result" name="search.count" template="Magento_CatalogSearch::count.phtml" cacheable="false">

That will yield a glorious:

Fatal error: Uncaught Error: Call to a member function getLoadedProductCollection() on boolean. Why?!

Thank you for your help.

2
  • you are replacing result.phtml by count.phtml? Sep 10, 2018 at 11:52
  • No, I am adding count.phtml to display the number of search results. Notice how in the Catalog XML, the subsequent call does not replace the former call(s). Sep 10, 2018 at 12:04

1 Answer 1

0

Magento make objects boolean(false) if class can't be found. Problem with Block object, not with *.phtml file

1
  • But the class is applied for search.result. It does exist, it's just not designed to be replicated. I don't quite get what that missing element is. Sep 12, 2018 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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