/** * Returns the root category id * * @param \Shopware\Models\Category\Category $category * @return integer */ public static function getRootIdByCategory(Shopware\Models\Category\Category $category) { while ($category->getParentId()) { $parent = $category->getParent(); if ($parent->getLevel() == 0) { break; } $category = $parent; } return $category->getId(); }