I have a custom category indexer which grabs Magento categories and index them to a search service. Within each category I need to index it's URL which I do by code
$url = $category->getUrl();
where $category
is instance of Magento\Catalog\Model\Category
.
The issue is when the store is set to use Secure URLs in front end. Then this code always return the not-secure URL. Do you know how to get the secure one?
With product I solved it with code
$url = $product->getUrlModel()->getUrl($product, ['_secure' => true]);
because simple $url = $product->getProductUrl();
returned a not-secure URL as well.
However from Category I don't have access to any UrlModel
or any way how to pass _secure
parameter to getUrl()
method.
Thanks for any help!