I have written a helper function that should take any product from a `list.phtml`, check if it has a parent (config) and if so return the parent's url instead of the simple product's url.

```
 public function getProductUrl($product)
    {
    if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) {
        return $product->getProductUrl();
    } else {
        $ids = $this->_config->getParentIdsByChild($product->getId());

        if (isset($ids[0])) {
            $configProduct = $this->_productRepository->getById($ids[0], false, $this->_storeManager->getStore()->getId());
            return $configProduct->getUrlModel()->getUrl($configProduct);
        } else {
            return $product->getProductUrl();
        }
    }
}

```

It basically works but it does not return the SEO url for the config product.
It looks like this: `https://www.example.com/catalog/product/view/id/29/s/my-awesome-product/category/4/`

For testing I also tried to load the entire product before creating the url, no difference.

What can I do to make it return the SEO url?

Thank you