0

For instance when visiting pages like example.com/men?p=2

Already tried with getting the current category from the registry, but then i would get only the url of the category (so only example.com/men)

Does anyone know how this could be implemented?

1 Answer 1

1

To get the current category url with parameters you can add the UrlInterface to the constructor and call the getCurrentUrl () method in the necessary method:

    protected urlInterface;
    public function __construct(
    ... \Magento\Framework\UrlInterface $urlInterface ... 
    ) {
        ...
        $this->urlInterface = $urlInterface;
        ...
    }
    public function execute()
    {
    ...
       $currentUrl = $this->urlInterface->getCurrentUrl();
    ...

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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