You can shorten any URL by placing the following code in the appropriate controller file. It can be used in both admin as well as catalog (store front)
1 | $this->url->shorten('Your Long URL here', $this->config->get('google_urlshortener_api'), $this->config->get('google_urlshortener_logs')); |
Example
$this->url->shorten('https://www.huntbee.com/documentation/', $this->config->get('google_urlshortener_api'), $this->config->get('google_urlshortener_logs'));
Note: If API key is incorrect or not properly setup, then the above code will return the input URL.