import { formatCategoryLink } from '@vue-storefront/core/modules/url/helpers'

// Duplicate of breadCrumbRoutes, to repalce it soon.
/** Parse category path for product/category  */
export function parseCategoryPath (categoryPath) {
  let routesArray = []
  for (let category of categoryPath) {
    routesArray.push({
      name: category.name,
      route_link: formatCategoryLink(category)
    })
  }

  return routesArray
}

import { formatCategoryLink } from '@vue-storefront/core/modules/url/helpers'

// Duplicate of breadCrumbRoutes, to repalce it soon.
/** Parse category path for product/category  */
export function parseCategoryPath (categoryPath) {
  let routesArray = []
  for (let category of categoryPath) {
    if (category.url_path == undefined) continue;
    routesArray.push({
      name: category.name,
      route_link: formatCategoryLink(category)
    })
  }

  return routesArray
}

Remove categories with unknown `url_path` from breadcrumbs
Remove categories with unknown `url_path` from breadcrumbs

In already 4 instances of Vue Storefront 1 with Magento 1, I've encountered the following issue: When categories are loaded into the breadcrumbs, they include the Magento Root Category (often with a name like **Default Category**). But because this Root Category serves a special purpose, the URL path is always empty. This fix simply checks whether the URL path is `undefined` and if so, it skips that category. Because the breadcrumbs are supposed to only contain categories with the URL path set.