kussin / OxidDoofinder

https://www.kussin.de/
Other
0 stars 0 forks source link

Redirecting OXID Default Search to Doofinder Results Layer #1

Open wmdkdkussin opened 9 months ago

wmdkdkussin commented 9 months ago

Redirect OXID eShop Default Search Requests like https://www.oxid-eshop.tld/index.php?stoken=B31DF395&lang=0&cl=search&searchparam=HMF01RDEU to Doofinder Result Layer (e.g. https://www.oxid-eshop.tld/#f2b9/fullscreen-brand-categories/m=and&q=HMF01RDEU).

wmdkdkussin commented 9 months ago

Replace SearchController.php with the following code:

<?php

namespace Kussin\Doofinder\Controller;

use OxidEsales\Eshop\Core\Registry;

class SearchController extends SearchController_parent
{    

    public function render()
    {
        // LOAD CONFIG
        $oConfig = Registry::getConfig();

        $sHomepageUrl = $this->getConfig()->getShopHomeURL();
        $sSearchParamForQuery = trim($oConfig->getRequestParameter('searchparam', true));

        if ($sSearchParamForQuery) {
            // TODO: Add your Doofinder search URL here
            $sHomepageUrl .= '/#acf7/fullscreen-brand-categories/m=and&q=' . urlencode($sSearchParamForQuery);
        }

        // Set HTTP status code 302 (Found)
        header("HTTP/1.1 302 Found");

        // Perform the redirection
        header("Location: $sHomepageUrl");
        exit;
    }
}