I have multi stores enabled in my Magento instance. I am trying to get product url for each store as I need to index data in Elasticsearch.
What I have tried but not getting the result with store appended in url.
$productId = 2; $storeId = 4; $product = $this->productRepository->getById($productId, false, $storeId); $product->setStoreId($storeId)->getUrlModel()->getUrlInStore($product, ['_escape' => true]);
I expect result as
Where as I get the result