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

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, privacy policy and cookie policy

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