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

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.