<?php
class ControllerExtensionModuleSubcategory extends Controller {
	public function index($setting) {
		static $module = 0;
		$lang_id = $this->config->get('config_language_id');
		$this->load->model('tool/image');
		
		
		$data['random'] = token(32);
		$data['module_name'] = $setting['name'];
		
		
		$this->load->model('catalog/category');
		
		$data['categories'] = [];
		
		foreach($setting['category_ids'] as $category_id){
			$category_info = $this->model_catalog_category->getCategory($category_id);
			if($category_info){
				
				$category_info['href'] = $this->url->link('product/category', 'path=' . $category_info['category_id']);
				
				$category_info['thumb'] = $this->model_tool_image->resize($category_info['image'] ? $category_info['image'] : 'placeholder.png', $setting['sizes']['desktop']['width'], $setting['sizes']['desktop']['height']);
				
				
				$data['categories'][] = $category_info;
			}
		}
		
		$data['sizes'] = $setting['sizes']['desktop'];
		
		$data['module'] = $module++;
		if($data['categories']){
			
			$this->document->addStyle('store/view/theme/dominik/assets/css/swiper-bundle.min.css');
			$this->document->addScript('store/view/theme/dominik/assets/js/swiper-bundle.js');
			
			return $this->load->view('extension/module/subcategory', $data);
		}
		
	}
}