We have a magento store which mainly features the contents and it has only 12 - 15 products. So client wants cms page and static block content also to be included on search. I can search only under cms page or static block by using like and getcollection methods. But i cant be successful with combining product search/cms page search.
Please can someone help me with this
Use the below code snippet if you want to show CMS Static Block from template phtml file in Magento 2: echo $this->getLayout() ->createBlock('Magento\Cms\Block\Block') ->setBlockId('your_block_identifier') ->toHtml(); For another block within CMS Block in Magento 2, please use the below code to show it.
You can get Specific Blocks data by Identifier using Get Cms Blocks data by an identifier. You need to instantiate Magento\Cms\Api\BlockRepositoryInterface in __construct() method of Class. From Template file, You can access all the Static Block by iterate over a loop on a collection.
To include CMS pages in default magento search we could use the below extension
http://www.magentocommerce.com/magento-connect/tangkoko/extension/1218/tangkoko--fidesio-cms-search
I hope, it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With