Question

I want to fetch cms page content using Search.?

If anyone have any idea related to CMS Pages Content Search.

Can anyone help me?

Was it helpful?

Solution

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$queryText = $this->queryFactory->get()->getQueryText();

$pagesCollection=$objectManager->create('Magento\Cms\Model\Page')->getCollection()

                            ->addFieldToFilter('is_active',1)
                            ->addFieldToFilter(
                                            array('title','content'),
                                                array(
                                                    array('like'=>'%'.$queryText.'%'), 
                                                    array('like'=>'%'.$queryText.'%')
                                                )
                                            );
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top