0

I am using the Amasty Layered Navigation extension. In the past I added this line of code-

 $matchedAlias = trim($matchedAlias, '/'); 

to the Router.php file in the extension. Since they updated the extension I can't add it to its old location. THe matchedAlias variable no longer exists so I need to trim something else. Anyone know where I could try something in here?

private function getSeoPartAndIdentifier($identifier, $request)
{
    $seoPart = '';
    $filterWord = $this->helper->getFilterWord();
    if ($filterWord) {
        if (strpos($identifier, '/' . $filterWord . '/') !== false) {
            $filterWordPosition = strpos($identifier, '/' . $filterWord . '/');
            $seoPart = substr(
                $identifier,
                $filterWordPosition + strlen('/' . $filterWord . '/')
            );
            $identifier = substr($identifier, 0, $filterWordPosition);
        } else {
            $this->checkSeoParams($request);
            $request->setMetaData(Data::SKIP_REQUEST_FLAG, true);
        }
    } else {
        $lastSlashPosition = strrpos($identifier, "/");
        $lastSlashPosition = ($lastSlashPosition === false) ? 0 : $lastSlashPosition;
        $seoPart = substr($identifier, $lastSlashPosition + 1);
        $identifier = substr($identifier, 0, $lastSlashPosition);
    }

    return [$seoPart, $identifier];
}

/**
 * @param $identifier
 * @param $request
 *
 * @return string
 */
private function removeSuffix($identifier, $request)
{
    if (trim($identifier, '/') && $this->getSeoSuffix()) {
        $suffixPosition = strrpos($identifier, $this->getSeoSuffix());

        if ($suffixPosition !== false
            && ($suffixPosition == strlen($identifier) - strlen($this->getSeoSuffix()))
        ) {
            $identifier = substr($identifier, 0, $suffixPosition);
            if (!$this->urlHelper->getAddSuffixSettingValue() && !$request->isAjax()) {
                $request->setMetaData(Data::SEO_REDIRECT_MISSED_SUFFIX_FLAG, true);
            }
        } elseif ($this->urlHelper->getAddSuffixSettingValue() && !$request->isAjax()) {
            $request->setMetaData(Data::SEO_REDIRECT_MISSED_SUFFIX_FLAG, true);
        }
    }

    return $identifier;
}

/**
 * @param RequestInterface $request
 * @param $identifier
 * @param array $params
 *
 * @return $this
 */
public function modifyRequest(RequestInterface $request, $identifier, $params = [])
{
    if (strlen($identifier)) {
        $request->setMetaData(Data::HAS_ROUTE_PARAMS, true);
        if ($this->isSuffixRemoved) {
            $identifier .= $this->getSeoSuffix();
        }

        $request->setPathInfo($identifier);
    }

    $request->setParams($params);
         $matchedAlias = trim($matchedAlias, '/');
    $request->setMetaData(Data::HAS_PARSED_PARAMS, true);

    return $this;
}

Your Answer

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

Browse other questions tagged or ask your own question.