I have a dropdown list containing categories and subcategories from my OpenCart shop, however I cannot seem to get the SEO keyword URL to show as the option value:
<select name="cat_id" id="category-select" class="span4">
<option value="">Browse by category</option>
<?php
$cats = $this->model_catalog_category->getCategories();
foreach ($cats as $cat) {
echo '<option value="' . $this->url->addRewrite('product/category', '&category_id=' . $cat['category_id']) . '">' . $cat['name'] . '</option>';
$subcats = $this->model_catalog_category->getCategories($cat['category_id']);
foreach ($subcats as $subcat) {
echo '<option value="' . $this->url->addRewrite('product/category', '&category_id=' . $subcat['category_id']) . '">- ' . $subcat['name'] . '</option>';
}
}
?>
</select>
I am new to OpenCart and not quite sure about what needs to go in the addRewrite function. Can't seem to find any mention of this in the OpenCart documentation either.