1

I want to fetch cms page content using Search.?

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

Can anyone help me?

1

1 Answer 1

1
$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.'%')
                                                )
                                            );
14
  • Have Any extension for it?
    – Moin Malek
    Feb 28, 2017 at 10:28
  • NO, above code use in controller Feb 28, 2017 at 10:29
  • Can I create Any Block Or Model File?
    – Moin Malek
    Feb 28, 2017 at 10:42
  • any where you can use but just need to replace $queryText Feb 28, 2017 at 10:44
  • So In my custom module,there are following folder etc,controller and view
    – Moin Malek
    Feb 28, 2017 at 10:48

Your Answer

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

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