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

Your Answer

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

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