Opencart - load only some categories? -
can me? have module. need load 10 categories (for example id 2,5,10,14 etc..). here's code:
//categories $this->load->model("catalog/category"); $allcategories = $this->model_catalog_category->getcategories(array()); $categoria_shop = array(); foreach ($allcategories $key => $value) { $categoria_shop[$value['name']] = $value['category_id']; } $categoria_shop_nezaradene = 69;
how can add id's of categories
in catalog/model/catalog/category.php
file, can see function getcategories()
has optional parent_id
parameter , must int
, try this:
// not tested $category_ids = array(2, 5, 10, 14); $categoria_shop = array(array()); foreach($category_ids $category_id) { $categories = $this->model_catalog_category->getcategories($category_id); foreach ($categories $key => $value) { $categoria_shop[][$value['name']] = $value['category_id']; } }
output example:
$categoria_shop[0]['cat_name2'] = 1; $categoria_shop[1]['cat_name5'] = 2; $categoria_shop[2]['cat_name10'] = 3; $categoria_shop[3]['cat_name14'] = 4;
Comments
Post a Comment