Попробовал вывести такую таблицу на странице подкатегории, вывелась нормально https://prnt.sc/w8if23, а вот тут https://prnt.sc/w3cof3 не хочет... Не пойму в чем разница.
Контроллер
$data['products_t'] = array();
$filter_data_t = array(
'filter_category_id' => $category_id
//'filter_sub_category' => true,
//'filter_filter' => $filter,
//'sort' => $sort,
//'order' => $order,
//'start' => ($page - 1) * $limit,
//'limit' => $limit
);
$product_total = $this->model_catalog_product->getTotalProducts($filter_data_t);
$products_t = $this->model_catalog_product->getProducts($filter_data_t);
$data['attribute_groups'] = array();
foreach ($products_t as $product_info) {
//$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_compare_width'), $this->config->get($this->config->get('config_theme') . '_image_compare_height'));
} else {
$image = false;
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
$attribute_data = array();
$attribute_groups = $this->model_catalog_product->getProductAttributes($product_info['product_id']);
foreach ($attribute_groups as $attribute_group) {
foreach ($attribute_group['attribute'] as $attribute) {
$attribute_data[$attribute['attribute_id']] = $attribute['text'];
}
}
$data['products_t'][] = array(
'product_id' => $product_info['product_id'],
'name' => $product_info['name'],
'thumb' => $image,
'price' => $price,
'special' => $special,
'minimum' => $product_info['minimum'] > 0 ? $product_info['minimum'] : 1,
'rating' => (int)$product_info['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'attribute' => $attribute_data,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
foreach ($attribute_groups as $attribute_group) {
$data['attribute_groups'][$attribute_group['attribute_group_id']]['name'] = $attribute_group['name'];
foreach ($attribute_group['attribute'] as $attribute) {
$data['attribute_groups'][$attribute_group['attribute_group_id']]['attribute'][$attribute['attribute_id']]['name'] = $attribute['name'];
}
}
}
Шаблон
<table class="table table-bordered">
<tr>
<th>Название</th>
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php $i = 0; ?>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<?php if ($i < 5) { ?>
<th><?php echo $attribute['name']; ?></th>
<?php } $i++; ?>
<?php } ?>
<?php } ?>
<th>Цена</th>
</tr>
<?php foreach ($products_t as $product) { ?>
<tr>
<td><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></td>
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php $i = 0; ?>
<?php foreach ($attribute_group['attribute'] as $key => $attribute) { ?>
<?php if ($i < 5) { ?>
<?php if (isset($product['attribute'][$key])) { ?>
<td><?php echo $product['attribute'][$key]; ?></td>
<?php } else { ?>
<td></td>
<?php } ?>
<?php } $i++; ?>
<?php } ?>
<?php } ?>
<td><a type="button" class="btn btn-primary btn-block" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><?php echo $product['price']; ?></a></td>
</tr>
<?php } ?>
</table>