A
A
AndrewSHkod2020-09-02 18:10:01
opencart
AndrewSHkod, 2020-09-02 18:10:01

How to get all subcategories of Opencart?

How to teach all neighboring subcategories of this subcategory.
CMS opencart.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pashok Doom, 2020-09-02
@AndrewSHkod

$data['categories'] = array();

            $results = $this->model_catalog_category->getCategories($category_id);

      if (!$results && isset($this->request->get['path'])) {
        $parts = explode('_', $this->request->get['path']);
        $cur_id = array_pop($parts);
        if (!empty($parts)) {
          $results = $this->model_catalog_category->getCategories(array_pop($parts));
        }
      }
      
            foreach ($results as $result) {
                $filter_data = array(
                    'filter_category_id'  => $result['category_id'],
                    'filter_sub_category' => true
                );

                $data['categories'][] = array(
                    'name' => $result['name'],
          'category_id' => $result['category_id'],
          'category_current' => isset($cur_id) && $cur_id ? $cur_id : false,
                    'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
                );
            }

This is how I displayed it inside the category. If there are no children, display adjacent ones

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question