Example #1
0
 /**
  * Retrieve category Url from the document source.
  * Done from the document source to prevent having to use addUrlRewrite to result on category collection.
  *
  * @param \Magento\Catalog\Model\Category $category The category.
  *
  * @return string
  */
 private function getCategoryUrl($category)
 {
     $documentSource = $category->getDocumentSource();
     if ($documentSource && isset($documentSource['url_path'])) {
         $urlPath = is_array($documentSource['url_path']) ? current($documentSource['url_path']) : $documentSource['url_path'];
         $url = trim($this->urlBuilder->getUrl($urlPath), '/') . $this->categoryUrlSuffix;
         return $url;
     }
     return $category->getUrl();
 }