I am working on fetching category URL for stores which are part of two different websites on a multiwebsite setup i.e abc.com and abc.co.uk, Issue happens when I fetch URL for abc.co.uk it returns me the URL of abc.com only. I have tried fetching with below solutions but none of them has worked:
1) Here in collection factory class I used is as below and latter is the code
$collection = $this->_categoryCollectionFactory->getCollection()->setStoreId($storeId)->addAttributeToSelect('*')->addIsActiveFilter();
2) I looped through all the categories and tried fetching it from repository
3) Another solution tried with looping the categories fetched based on store id, looping it and generating URL as below, Although below URL provides me with a solution for correct website URL but still the category URL path is incorrect.
Any help or guidance on this would be much appreciated.