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

class ControllerModuleSpecial extends ControllerProductProductList {

	public function index($setting=null) {
		$this->language->load('module/special');
		$this->load->model('catalog/special_action');

		if(isset($setting['order_promotion_id']) && ($setting['order_promotion_id']!=Type_DefaultValues::Tp_PromocaoGeral)){
			$title = $this->model_catalog_special_action->getSpecialAction($setting['order_promotion_id'])['description'];
            $filter = '&order_promotion_id='.$setting['order_promotion_id'];
		}else{
			$title  = $this->language->get('heading_title') ;
			$filter = '';
		}

		$setting = array_merge($setting, ['sort'=>'od.date_product_added','order'=>'DESC']);

        $this->data['order_promotion_id'] = $setting['order_promotion_id'];
		$this->data['heading_title']    = $title;
        $this->data['link']             = $this->url->link('product/special', $filter, 'SSL');
		$this->data['grid']             = (isset($setting['entry_type'])) ? $setting['entry_type'] : 0;
        $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/moduleSpecial' => $setting
        );

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

}
