{% if count_attr > '1' %}
<div class="box sf-attribute sf-attribute-{{ attribute.attribute_id }} sf-{{ attribute.type }} {% if is_collapsed %} is-collapsed {% endif %}" data-id=" attribute-{{ attribute.attribute_id }}">
<div class="box-heading">{{ attribute.attribute_name }}</div>
<div class="box-content">
<ul class="sf_li {% if not journal2.settings.get('filter_show_box') %} hide-checkbox {% endif %}">
{% for value in attribute.values %}
<li><label><input data-keyword="{{ value.keyword }}" type="checkbox" name="attribute[{{ attribute.attribute_id }}]" value="{{ value.text }}">{{ value.name }}</label></li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
/* attributes */
$results = $this->model_journal2_super_filter->getAttributes($data);
foreach ($results as $key => $result) {
$display_mode = Journal2Utils::getProperty($module_data, 'attributes.' . $key, 'on');
if ($display_mode === 'off') {
continue;
}
$values = array();
foreach ($result['values'] as $value) {
$values[] = array(
'text' => rawurlencode(trim($value['text'])),
'name' => trim($value['text']) . ( $show_product_count ? ' (' . $value['total'] . ')' : ''),
'keyword' => $this->keyword($result['attribute_name'] . " " . $value['text'])
);
}
$this->data['attribute'] = array(
'attribute_id' => $result['attribute_id'],
'attribute_name' => $result['attribute_name'],
'display_mode' => $display_mode,
'type' => Journal2Utils::getProperty($module_data, 'attributes_type.' . $key, 'multi'),
'values' => $values,
);
$this->data['count_attr'] = count($this->data['attribute']['values']);
$this->template = 'journal2/module/super_filter_attributes.tpl';
$filter_groups[] = array(
'sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.a_' . $result['attribute_id']),
'html' => $this->render()
);
}
public function getAttributes($data = array()){
if(isset($data['attributes']) && !empty($data['attributes'])) {
$product_attributes = $this->getProductAttributes($data);
foreach ($data['attributes'] as $attribute_id => $value) {
foreach($product_attributes as $key => $attribute) {
if($key == $attribute_id) {
unset($product_attributes[$key]);
}
}
$temp_data = $data;
unset($temp_data['attributes'][$attribute_id]);
foreach($this->getProductAttributes($temp_data) as $key => $attribute){
if($key == $attribute_id) {
$product_attributes[$attribute_id] = $attribute;
}
}
}
$results = $product_attributes;
}else{
$results = $this->getProductAttributes($data);
}
ksort($results);
return $results;
}
private function getProductAttributes($data = array()){
$data['start'] = 0;
$data['limit'] = PHP_INT_MAX;
$products = $this->getProducts($data);
if (count($products) == 0) {
return array();
}
$sql = "SELECT pa.product_id, MAX(a.attribute_id) as attribute_id, MAX(ad.name) as attribute_name, MAX(pa.text) text, COUNT(*) total FROM `". DB_PREFIX . "product_attribute` pa LEFT JOIN `". DB_PREFIX . "attribute` a ON a.attribute_id = pa.attribute_id LEFT JOIN `". DB_PREFIX . "attribute_description` ad ON ad.attribute_id = a.attribute_id";
$sql .= " WHERE pa.product_id IN (" . implode(",", $products) . ")";
$sql .= " AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "'";
$sql .= " GROUP BY lower(pa.text), a.attribute_id HAVING COUNT(*) > 0";
$query = $this->db->query($sql);
$results = array();
foreach ($query->rows as $row) {
if (!isset($results[$row['attribute_id']])) {
$results[$row['attribute_id']] = array(
'attribute_id' => $row['attribute_id'],
'attribute_name' => $row['attribute_name'],
'values' => array()
);
}
$results[$row['attribute_id']]['values'][] = array(
'text' => $row['text'],
'total' => $row['total'],
);
}
foreach ($results as $attribute_id => &$value) {
usort($value['values'], array('ModelJournal2SuperFilter', 'cmpAttrs'));
}
return $results;
}
RewriteCond %{QUERY_STRING} journal_blog_category_id=1$
RewriteRule ^(.*)$ https://proteplo.org/blog/? [R=301,L]
RewriteCond %{QUERY_STRING} ^_route_=/blog/?journal_blog_category_id=1$
RewriteRule ^(.*)$ https://proteplo.org/blog/? [R=301,L]
if (!empty($data['filter_name'])) {
$implode = array();
$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name'])));
foreach ($words as $word) {
$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
}
if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.seriya_nasos LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.opis_name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.dop_name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
}
$file_tepl = "";
// Если поле выбора вложения не пустое - закачиваем его на сервер
if (!empty($_FILES['file_t']['tmp_name']))
{
// Закачиваем файл
$path = $_FILES['file_t']['name'];
if (copy($_FILES['file_t']['tmp_name'], $path)) $file_tepl = $path;
}
$thm = 'Файл';
$msg = "Файл";
$mail_to = 'мойемейл@gmail.com';
// Отправляем почтовое сообщение
if(empty($file_tepl)) mail($mail_to, $thm, $msg);
else send_mail($mail_to, $thm, $msg, $file_tepl);
// Вспомогательная функция для отправки почтового сообщения с вложением
function send_mail($to, $thm, $html, $path)
{
$fp = fopen($path,"r");
if (!$fp)
{
print "Файл $path не может быть прочитан";
exit();
}
$file = fread($fp, filesize($path));
fclose($fp);
$boundary = "--".md5(uniqid(time())); // генерируем разделитель
$headers .= "MIME-Version: 1.0\n";
$headers .="Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
$multipart .= "--$boundary\n";
$kod = 'utf-8'; // или $kod = 'windows-1251';
$multipart .= "Content-Type: text/html; charset=$kod\n";
$multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n";
$multipart .= "$html\n\n";
$message_part = "--$boundary\n";
$message_part .= "Content-Type: application/octet-stream\n";
$message_part .= "Content-Transfer-Encoding: base64\n";
$message_part .= "Content-Disposition: attachment; filename = \"".$path."\"\n\n";
$message_part .= chunk_split(base64_encode($file))."\n";
$multipart .= $message_part."--$boundary--\n";
if(!mail($to, $thm, $multipart, $headers))
{
echo "К сожалению, письмо не отправлено";
exit();
}
}
Код по атрибутам для фильтра скинул выше.