@SooR подскажите, пожалуйста, как получить отфильтрованный массив товаров? Делаю со страницы категории экспорт товаров в PDF формат. Раньше делал так, а как сейчас в новой версии, не понимаю
if ($category_info) {
// OCFilter start
if (isset($this->request->get['filter_ocfilter'])) {
$filter_ocfilter = $this->request->get['filter_ocfilter'];
} else {
$filter_ocfilter = '';
}
// OCFilter end
if (isset($this->request->get['filter'])) {
$filter = $this->request->get['filter'];
} else {
$filter = '';
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['limit'])) {
$limit = (int)$this->request->get['limit'];
} else {
$limit = $this->config->get($this->config->get('config_theme') . '_product_limit');
}
require('system/library/mpdf/mpdf.php');
$data['heading_title'] = $category_info['name'];
$data['text_refine'] = $this->language->get('text_refine');
$data['text_empty'] = $this->language->get('text_empty');
$data['text_quantity'] = $this->language->get('text_quantity');
$data['text_manufacturer'] = $this->language->get('text_manufacturer');
$data['text_model'] = $this->language->get('text_model');
$data['text_price'] = $this->language->get('text_price');
$data['products'] = array();
$filter_data = array(
'filter_category_id' => $category_id,
'filter_filter' => $filter,
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
'limit' => 10000
);
// OCFilter start
$filter_data['filter_ocfilter'] = $filter_ocfilter;
// OCFilter end
$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($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $result['price'];
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'model' => $result['model'],
'collection' => $result['collection'],
'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),
'price' => (int)$price . ' руб',
'special' => $special,
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
//
$template = 'product/category';
//$this->load->library('mpdf/mpdf');
$headerHTML = '
<div style="float: left; width: 340px; text-align: left">
<a target="_blank" href="' . HTTPS_SERVER . '"><img style="max-width:100%;max-height:180px" src="/image/'.$this->config->get('config_logo').'" /></a>
</div>
<div style="float: right; width: 340px; text-align: right; color: #808180">
' . nl2br($this->config->get('config_address')) . '<br/>
' . $this->config->get('config_telephone') . '<br/>
' . $this->config->get('config_email') . '<br/>
<a style="color:blue; text-decoration:none;" target="_blank" href="' . HTTPS_SERVER . '">' . HTTPS_SERVER . '</a>
</div>
<div class="clear"></div>
<hr>
';
//print_r($this->config);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/price_to_pdf.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/price_to_pdf.tpl';
} else {
$this->template = 'default/template/product/price_to_pdf.tpl';
}
$today = date("d.m.Y");
$mpdf = new mPDF('utf-8', 'A4', 7, 'Helvetica', 20, 5, 35, 5);
$mpdf->name = $category_info['name'] . '.pdf';
$mpdf->SetHTMLHeader($headerHTML);
$mpdf->WriteHTML($this->load->view('product/price_to_pdf.tpl', $data));
$mpdf->Output('Прайс_' . $today . '.pdf', 'D');
}