steve07 Posted August 22, 2023 at 08:32 AM Share Posted August 22, 2023 at 08:32 AM как получить отфильтрованный массив товаров? Делаю со страницы категории экспорт товаров в PDF формат, в 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*/ // OCFilter start if ($this->registry->get('ocfilter') && $this->ocfilter->startup() && $this->ocfilter->api->useSubCategory() && $this->ocfilter->api->isSelected() && empty($filter_data['filter_sub_category'])) { $filter_data['filter_sub_category'] = true; } // OCFilter end $product_total = $this->model_catalog_product->getTotalProducts($filter_data); $results = $this->model_catalog_product->getProducts($filter_data); // Unit of measure → $this->load->model('extension/module/unit_of_measure'); $product_ids = array(); foreach ($results as $result) { $product_ids[] = $result['product_id']; } $units_result = $this->model_extension_module_unit_of_measure->getUnits($product_ids); // ← Unit of measure 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']); if ($this->currency->has($this->config->get('config_currency2')) && ($this->config->get('config_currency2') != $this->session->data['currency'])) { $special .= ' (' . $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->config->get('config_currency2')) . ')'; } } else { $special = false; } $data['products'][] = array( 'unit_of_measure' => isset($units_result[$result['product_id']]) ? html_entity_decode($units_result[$result['product_id']], ENT_QUOTES, 'UTF-8') : '', '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/category_price.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/category_price.tpl'; } else { $this->template = 'default/template/product/category_price.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/category_price.tpl', $data)); $mpdf->Output('Прайс_' . $today . '.pdf', 'D'); } 0 Quote Link to comment Share on other sites More sharing options...
AlexDW Posted August 22, 2023 at 09:19 AM Share Posted August 22, 2023 at 09:19 AM вероятно раскомментировать части кода с $filter_ocfilter 0 Quote модули для удобной работы с Opencart Link to comment Share on other sites More sharing options...
steve07 Posted August 22, 2023 at 10:16 AM Author Share Posted August 22, 2023 at 10:16 AM В 22.08.2023 в 14:19, AlexDW сказал: вероятно раскомментировать части кода с $filter_ocfilter не помогает, это при старой версии фильтра было... и все ок работало. С новой не работает 0 Quote Link to comment Share on other sites More sharing options...
AlexDW Posted August 22, 2023 at 11:29 AM Share Posted August 22, 2023 at 11:29 AM отслеживайте что у вас в $filter_data передается 0 Quote модули для удобной работы с Opencart Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.