<?php
class ControllerCommonHome extends Controller {
public function index() {
$this->document->setTitle($this->config->get('config_meta_title'));
$this->document->setDescription($this->config->get('config_meta_description'));
$this->document->setKeywords($this->config->get('config_meta_keyword'));
if (isset($this->request->get['route'])) {
$this->document->addLink($this->config->get('config_url'), 'canonical');
}
$this->load->language('product/category');
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$arr_category = $this->model_catalog_category->getCategories(0);
//foreach ($arr_category as $id) {
foreach ($arr_category as $category_item) {
//$category_id = $category_item['category_id'];
//$category_info = $this->model_catalog_category->getCategory($category_item['category_id']);
//print_r($category_info);
echo "---<br>" . PHP_EOL;
echo "\$category_item<br>" . PHP_EOL;
echo "<pre>" . PHP_EOL;
print_r($category_item) . PHP_EOL;
echo "</pre>" . PHP_EOL;
//$this->document->setTitle($category_info['meta_title']);
//$this->document->setDescription($category_info['meta_description']);
//$this->document->setKeywords($category_info['meta_keyword']);
$data['categories'] = array();
//$data['heading_title'] = $category_info['name'];
$data['categories'][$category_item['category_id']]['name'] = $category_item['name'];
//$data['products'] = array();
$data['categories'][$category_item['category_id']]['products'] = array();
$filter_data = array(
//'filter_category_id' => $category_id,
'filter_category_id' => $category_item['category_id'],
);
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
$results = $this->model_catalog_product->getProducts($filter_data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
$data['categories'][$category_item['category_id']]['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
//'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
// 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
};
echo "---<br>" . PHP_EOL;
echo "\$data['categories'][\$category_item['category_id']]<br>" . PHP_EOL;
echo "<pre>" . PHP_EOL;
print_r($data['categories'][$category_item['category_id']]) . PHP_EOL;
echo "</pre>" . PHP_EOL;
//$data['continue'] = $this->url->link('common/home');
//
//$data['column_left'] = $this->load->controller('common/column_left');
//$data['column_right'] = $this->load->controller('common/column_right');
//$data['content_top'] = $this->load->controller('common/content_top');
//$data['content_bottom'] = $this->load->controller('common/content_bottom');
//$data['footer'] = $this->load->controller('common/footer');
//$data['header'] = $this->load->controller('common/header');
//
//$this->response->setOutput($this->load->view('product/category', $data));
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/home', $data));
}
}
<div class="row">{% for category in categories|batch((categories|length / 4)|round(1, 'ceil')) %}
<div class="col-sm-3">
<ul>
{% for child in category %}
<li><a href="{{ child.href }}">{{ child.name }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}</div>