<?php
$loader = $this->registry->get('load');
$loader->controller('product/productList');

class ControllerModuleFeatured extends ControllerProductProductList {

	public function index($setting=null) {
        $this->language->load('module/featured');

        if (!isset($setting['featured_product'])) {
            return false;
        }

        if (!isset($setting['featured_title'])) {
            $setting['featured_title'] = $this->config->get('featured_title');
        }

        if (empty($setting['featured_title'])) {
            $setting['featured_title'] = $this->language->get('heading_title');
        }

        $name = str_replace('.php', '', basename( __FILE__ ));
        $index = '';
        if (isset($setting['featured_index'])) {
            $index = '&index='. $setting['featured_index'];
        }
            $link = $this->url->link(
            'product/modules_in_page',
            '&name=' . $name . $index,
            'SSL'
        );

		$this->data['heading_title'] = $setting['featured_title'];

		$this->data['grid'] = (isset($setting['entry_type'])) ? $setting['entry_type'] : 0;
		$this->data['link'] = $link;

		$this->data['productsIds'] = $setting['featured_product'];
		$this->data['product_list_title_style'] =  $this->config->get('product_list_title_style');
        $this->data['Type_ProductListTitleStyle'] = $this->load->typeForTwig('Type_ProductListTitleStyle');

        $this->childrenData = array(
            'product/productList/moduleFeatured' => $setting
        );


    	$this->render('module/featured');
	}

}
