Closed
Description
Preconditions
- Magento 2.1.8
- PHP 7
- MySQL 5.6
Steps to reproduce
$categoryCollection = $this->categoryCollectionFactory->create();
$categoryCollection->setStoreId(1);
$categoryCollection->addUrlRewriteToResult();
echo $categoryCollection->getUrl();
Expected result
- should return the url of category in store 1
Actual result
- Instead it returns the url of default store
The problem is that Magento\Catalog\Model\ResourceModel\Category\Collection::joinUrlRewrite always use the store id from the store manager. I think that it should instead use the storeId set on the actual collection.