1

I want to configure Nextopia Extension, i installed it properly after that when i go to this URL http://mysite.dev.us/nsearch, i get an error like this: enter image description here

And the file /app/code/Nextopia/Search/Controller/Index/Index.php

<?php
namespace Nextopia\Search\Controller\Index;
use \Nextopia\Search\Helper\Data as NsearchHelperData;
use \Magento\Catalog\Controller\Category\View as Action;
use \Magento\Catalog\Api\CategoryRepositoryInterface;
use \Magento\Framework\View\Result\PageFactory;
use Magento\Catalog\Model\Layer\Resolver;
class Index extends Action
{
 /** @var \Magento\Framework\View\Result\Page */
 protected $resultPageFactory;
 /** @var \Nextopia\Search\Helper\Data */
 protected $nsearchHelperData;
 /** @var \Magento\Catalog\Model\Design */
 protected $catalogDesign;
 /**
 * Constructor
 *
 * @param \Magento\Framework\App\Action\Context $context
 * @param \Magento\Catalog\Model\Design $catalogDesign
 * @param \Magento\Catalog\Model\Session $catalogSession
 * @param \Magento\Framework\Registry $coreRegistry
 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
 * @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
 * @param Resolver $layerResolver
 * @param CategoryRepositoryInterface $categoryRepository
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 */
 public function __construct(
 \Magento\Framework\App\Action\Context $context,
 \Magento\Catalog\Model\Design $catalogDesign,
 \Magento\Catalog\Model\Session $catalogSession,
 \Magento\Framework\Registry $coreRegistry,
 \Magento\Store\Model\StoreManagerInterface $storeManager,
 \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
 PageFactory $resultPageFactory,
 \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory,
 Resolver $layerResolver,
 CategoryRepositoryInterface $categoryRepository, 
 NsearchHelperData $nsearchHelperData
 ) {
 $this->resultPageFactory = $resultPageFactory;
 $this->nsearchHelperData = $nsearchHelperData;
 $this->catalogDesign = $catalogDesign;
 parent::__construct($context, $catalogDesign, $catalogSession, $coreRegistry, $storeManager, 
 $categoryUrlPathGenerator, $resultPageFactory, $resultForwardFactory, $layerResolver, $categoryRepository);
 }
 /**
 * Blog Index, shows a list of recent blog posts.
 *
 * @return \Magento\Framework\Controller\ResultInterface
 */
 public function execute()
 {
 $storeId = $this->nsearchHelperData->getCurrentStoreId();
 $resultsPage = $this->resultPageFactory->create();
 if(!$this->nsearchHelperData->isEnabled($storeId) && !$this->nsearchHelperData->isDemo($storeId)) {
 $resultsPage->setPath("catalogsearch/result/index", $this->getRequest()->getParams());
 return $resultsPage;
 }
 /**
 * Since we don't have catalogsearch_result_index in Nxt extension,
 * the next line takes the catalog result layout settings from the client's theme,
 * We need it to have the current catalog layout and all fonctionalities of the sidebar(Add to wishlist, Add to compage...)
 */
 $resultsPage->addHandle("catalogsearch_result_index");
 $keywords = $this->getRequest()->getParam("q");
 $resultsPage->getConfig()->getTitle()->set($this->nsearchHelperData->getLabelSearchResultPage($storeId)." ".$keywords);
 return $resultsPage;
 }
}
asked Sep 13, 2019 at 17:50

2 Answers 2

0

As you want redirect then you need use resultRedirectFactory(Magento\Framework\Controller\Result\RedirectFactory) instead of Result Page Factory $this->resultPageFactory->create();

 public function execute()
 {
 $storeId = $this->nsearchHelperData->getCurrentStoreId();
 if(!$this->nsearchHelperData->isEnabled($storeId) && !$this->nsearchHelperData->isDemo($storeId)) {
 //$resultsPage->setPath("catalogsearch/result/index", $this->getRequest()->getParams());
 //return $resultsPage;
 return $this->resultRedirectFactory->create()
 ->setPath("catalogsearch/result/index", $this->getRequest()->getParams());
 }
 $resultsPage = $this->resultPageFactory->create();
 /**
 * Since we don't have catalogsearch_result_index in Nxt extension,
 * the next line takes the catalog result layout settings from the client's theme,
 * We need it to have the current catalog layout and all fonctionalities of the sidebar(Add to wishlist, Add to compage...)
 */
 $resultsPage->addHandle("catalogsearch_result_index");
 $keywords = $this->getRequest()->getParam("q");
 $resultsPage->getConfig()->getTitle()->set($this->nsearchHelperData->getLabelSearchResultPage($storeId)." ".$keywords);
 return $resultsPage;
 }
answered Sep 13, 2019 at 18:23
0

Actually this was not a bug from Nextopia, I didn't register my Domain that is why I'm getting this error...

answered Oct 30, 2019 at 14:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.