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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -