Изменение административной части
controller
1
admin/controller/catalog/product.php
вставить после:
вставить после:
private function getForm() {
# Filter start
$this->document->addStyle('view/stylesheet/filter/filter.css');
# Filter end
вставить после:
$this->data['button_remove'] = $this->language->get('button_remove');
# Filter start
$this->data['tab_product_filter'] = $this->language->get('tab_product_filter');
$this->data['entry_values'] = $this->language->get('entry_values');
$this->data['text_select_category'] = $this->language->get('text_select_category');
# Filter end
2
admin/controller/common/header.php
вставить после:
вставить после:
$this->data['text_backup'] = $this->language->get('text_backup');
# Filter start
$this->data['text_filter'] = $this->language->get('text_filter');
# Filter end
вставить после:
$this->data['option'] = $this->url->link('catalog/option', 'token=' . $this->session->data['token'], 'SSL');
# Filter start
$this->data['filter'] = $this->url->link('catalog/filter', 'token=' . $this->session->data['token'], 'SSL');
# Filter end
language
3
admin/language/russian/catalog/product.php
вставить после:
$_['column_action'] = 'Действие';
# Filter start
$_['entry_values'] = 'Добавьте значения для этой опции.';
$_['tab_product_filter'] = 'Опции фильтра';
$_['text_select_category'] = 'Для начала, выберите категории для этого товара.';
# Filter end
4
admin/language/russian/common/header.php
вставить после:
$_['text_extension'] = 'Дополнения';
# Filter start
$_['text_filter'] = 'Фильтр товаров';
# Filter end
model
5
admin/model/catalog/product.php
вставить после:
вставить после:
вставить после:
вставить после:
вставить после:
$product_id = $this->db->getLastId();
# Start Filter
if (isset($data['product_to_value_id'])) {
foreach ($data['product_to_value_id'] as $option_id => $values) {
foreach ($values['values'] as $value_id) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_value SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$option_id . "', value_id = '" . (int)$value_id . "'");
}
}
}
# End filter
вставить после:
$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
if (isset($data['product_discount'])) {
foreach ($data['product_discount'] as $product_discount) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_discount['customer_group_id'] . "', quantity = '" . (int)$product_discount['quantity'] . "', priority = '" . (int)$product_discount['priority'] . "', price = '" . (float)$product_discount['price'] . "', date_start = '" . $this->db->escape($product_discount['date_start']) . "', date_end = '" . $this->db->escape($product_discount['date_end']) . "'");
}
}
# Start Filter
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_value WHERE product_id = '" . (int)$product_id . "'");
if (isset($data['product_to_value_id'])) {
foreach ($data['product_to_value_id'] as $option_id => $values) {
foreach ($values['values'] as $value_id) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_value SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$option_id . "', value_id = '" . (int)$value_id . "'");
}
}
}
# End filter
вставить после:
$data = array_merge($data, array('product_option' => $this->getProductOptions($product_id)));
# Filter start
$data = array_merge($data, array('product_to_value_id' => $this->getProductFilterValues($product_id)));
# Filter end
вставить после:
$this->db->query("DELETE FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
# Filter start
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_value WHERE product_id = '" . (int)$product_id . "'");
# Filter end
вставить после:
public function getProductCategories($product_id) {
$product_category_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
foreach ($query->rows as $result) {
$product_category_data[] = $result['category_id'];
}
return $product_category_data;
}
# Filter start
private function getProductFilterValues($product_id) {
$product_filter_value_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_value WHERE product_id = '" . (int)$product_id . "'");
foreach ($query->rows as $result) {
$product_filter_value_data[$result['option_id']]['values'][] = $result['value_id'];
}
return $product_filter_value_data;
}
# Filter end
view
6
admin/view/template/catalog/product_form.tpl
вставить после:
вставить перед:
вставить после:
<a href="#tab-links"><?php echo $tab_links; ?></a>
<!-- Filter start --><a href="#tab-product-filter"><?php echo $tab_product_filter; ?></a><!-- Filter end -->
вставить перед:
<div id="tab-attribute">
<!-- Filter start -->
<div id="tab-product-filter"><?php echo $text_select_category; ?></div>
<!-- Filter end -->
вставить после:
<script type="text/javascript"><!--
$('#tabs a').tabs();
$('#languages a').tabs();
$('#vtab-option a').tabs();
//--></script>
<script type="text/javascript"><!--
// Product filter start
var filter = {
update: function() {
var category_id = $('input[name=\'product_category[]\']:checked:last').val(), html = '';
if (category_id) {
$.get('index.php?route=catalog/filter/callback', 'token=<?php echo $token; ?>&category_id=' + category_id + (filter.product_id ? '&product_id=' + filter.product_id : ''), function(json) {
if (!json['message']) {
html += '<table class="form">';
$.each(json['options'], function(k, o) {
var values = '', selecteds = '';
html += '<tr' + (o['status'] == 0 ? ' class="disabled"' : '') + '>';
html += '<td width="20%"><b>' + o['name'] + '</b></td>';
html += '<td width="80%">';
if (o['values'].length) {
$.each(o['values'], function(kv, v) {
var checked = '';
if (v['selected']) {
selecteds += '<span id="v-' + v['value_id'] + '">' + v['name'] + o['postfix'] + '</span>';
checked += ' checked="checked"';
}
values += '<label><input type="checkbox" name="product_to_value_id[' + o['option_id'] + '][values][' + v['value_id'] + ']" value="' + v['value_id'] + '"' + checked + ' />' + v['name'] + o['postfix'] + '</label>';
});
if (!selecteds) selecteds = '<b><?php echo $text_select; ?></b>';
html += '<div class="switcher"><div class="selected">' + selecteds + '</div><div class="values">' + values + '</div>';
} else {
html += '<a href="index.php?route=catalog/filter/update&token=<?php echo $token; ?>&option_id=' + o['option_id'] + '" target="_blank"><?php echo $entry_values; ?></a>';
}
html += '</td>';
html += '</tr>';
});
html += '</table>';
} else {
html = '<p style="text-align:center;font-size:20px;">' + json['message'] + '</p>';
}
$('#tab-product-filter').html(html);
}, 'json');
} else {
$('#tab-product-filter').html('<p style="text-align:center;font-size:20px;"><?php echo $text_select_category; ?></p>');
}
},
product_id: 0
}
<?php if (isset($this->request->get['product_id'])) { ?>
filter.product_id = <?php echo $this->request->get['product_id']; ?>;
filter.update();
<?php } ?>
$('input[name=\'product_category[]\']').live('change', function() {
filter.update();
});
// Start filter switcher
$(document).ready(function(){
$('.switcher .selected').live('click', function() {
$('.values').hide();
if (!$(this).hasClass('active')) {
$('.switcher .selected').removeClass('active');
$('.switcher').removeClass('switcher-active');
$(this).addClass('active').parent().addClass('switcher-active');
$(this).next('.values').show();
} else {
$(this).removeClass('active').parent().removeClass('switcher-active');
$(this).next('.values').hide();
}
});
$('.switcher input').live('change', function() {
var selected = $(this).parents('.switcher').find('.selected');
var text = $(this).parent('label').text();
var length = selected.find('span').length;
selected.find('b').remove();
if ($(this).prop('checked')) {
selected.append('<span id="v-' + this.value + '">' + text + '</span>');
} else {
var span = $('#v-' + this.value);
if (length == 1) {
span.replaceWith('<b><?php echo $text_select; ?></b>');
} else {
span.remove();
}
}
});
});
$(document).click(function(e){
if ($(e.target).parents().filter('.switcher').length != 1) {
$('.values').hide();
$('.selected').removeClass('active');
}
});
// End filter switcher
//--></script>
7
admin/view/template/common/header.tpl
вставить после:
<li><a href="<?php echo $product; ?>"><?php echo $text_product; ?></a></li>
<!-- Filter start -->
<li><a href="<?php echo $filter; ?>"><?php echo $text_filter; ?></a></li>
<!-- Filter end -->
Изменение каталога
controller
8
catalog/controller/product/category.php
вставить после:
вставить после:
вставить после:
вставить после:
вставить после:
вставить после:
вставить перед:
вставить перед:
вставить перед:
$this->load->model('catalog/product');
# start filter
$this->load->model('catalog/filter');
# end filter
вставить после:
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = $this->config->get('config_catalog_limit');
}
# start filter
if (isset($this->request->get['filter_params'])) {
$filter_params = $this->request->get['filter_params'];
} else {
$filter_params = null;
}
# end filter
вставить после:
'filter_category_id' => $category_id,
# Product Filter start
'filter_params' => $filter_params,
# Product Filter end
вставить после:
$results = $this->model_catalog_product->getProducts($data);
# start filter products attributes
$filter_module = $this->config->get('filter_module');
if (isset($filter_module[0])) {
$filter_settings = $filter_module[0];
$show_type = $filter_settings['pco_show_type'];
$show_limit = (int)$filter_settings['pco_show_limit'];
$products_id = array();
foreach ($results as $result) $products_id[] = (int)$result['product_id'];
$product_options = array();
if ($products_id) {
$filter_options = $this->model_catalog_filter->getOptionsByProductsId($products_id);
foreach ($filter_options as $product_id => $options) {
array_splice($options, $show_limit);
foreach($options as $option) {
if ($show_type == 'inline') {
$product_options[$product_id][] = $option['name'] . ': <b>' . $option['values'] . '</b>';
} else {
$product_options[$product_id][] = array(
'name' => $option['name'],
'values' => $option['values']
);
}
}
}
}
}
# end filter products attributes
вставить после:
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
# start filter products attributes
if ($show_type == 'inline') {
if (isset($product_options[$result['product_id']])) {
$attributes = implode(' / ', $product_options[$result['product_id']]);
} else {
$attributes = '';
}
} else {
if (isset($product_options[$result['product_id']])) {
$attributes = $product_options[$result['product_id']];
} else {
$attributes = array();
}
}
# end filter products attributes
вставить после:
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
# start filter products attributes
'attributes' => $attributes,
# end filter products attributes
вставить перед:
$this->data['sorts'] = array();
# start filter
if (isset($this->request->get['filter_params'])) {
$url .= '&filter_params=' . $this->request->get['filter_params'];
}
# end filter
вставить перед:
$this->data['limits'] = array();
# start filter
if (isset($this->request->get['filter_params'])) {
$url .= '&filter_params=' . $this->request->get['filter_params'];
}
# end filter
вставить перед:
$pagination = new Pagination();
# start filter
if (isset($this->request->get['filter_params'])) {
$url .= '&filter_params=' . $this->request->get['filter_params'];
}
# end filter
9
catalog/controller/product/compare.php
вставить после:
вставить после:
вставить после:
удалить:
удалить:
$this->load->model('catalog/product');
# start filter
$this->load->model('catalog/filter');
# end filter
вставить после:
$this->data['attribute_groups'] = array();
# start filter products attributes
$products_id = $this->session->data['compare'];
$product_options = array();
if ($products_id) {
$filter_options = $this->model_catalog_filter->getOptionsByProductsId($products_id);
foreach ($filter_options as $product_id => $options) {
foreach($options as $option) {
if (isset($option['values']) && $option['values']) {
$product_options[$product_id][$option['option_id']] = $option['values'];
$this->data['attribute_groups'][$option['option_id']] = array(
'name' => '',
'attribute' => array($option['option_id'] => array('name' => $option['name']))
);
}
}
}
}
# end filter products attributes
вставить после:
if ($product_info['quantity'] <= 0) {
$availability = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$availability = $product_info['quantity'];
} else {
$availability = $this->language->get('text_instock');
}
# Filter start
if (isset($product_options[$product_id])) {
$attribute_data = $product_options[$product_id];
} else {
$attribute_data = array();
}
# Filter end
удалить:
$attribute_data = array();
$attribute_groups = $this->model_catalog_product->getProductAttributes($product_id);
foreach ($attribute_groups as $attribute_group) {
foreach ($attribute_group['attribute'] as $attribute) {
$attribute_data[$attribute['attribute_id']] = $attribute['text'];
}
}
удалить:
foreach ($attribute_groups as $attribute_group) {
$this->data['attribute_groups'][$attribute_group['attribute_group_id']]['name'] = $attribute_group['name'];
foreach ($attribute_group['attribute'] as $attribute) {
$this->data['attribute_groups'][$attribute_group['attribute_group_id']]['attribute'][$attribute['attribute_id']]['name'] = $attribute['name'];
}
}
10
catalog/controller/product/manufacturer.php
вставить перед:
вставить после:
вставить после:
вставить после:
$this->load->model('catalog/product');
# start filter
$this->load->model('catalog/filter');
# end filter
вставить после:
$results = $this->model_catalog_product->getProducts($data);
# start filter products attributes
$filter_module = $this->config->get('filter_module');
if (isset($filter_module[0])) {
$filter_settings = $filter_module[0];
$show_type = $filter_settings['pco_show_type'];
$show_limit = (int)$filter_settings['pco_show_limit'];
$products_id = array();
foreach ($results as $result) $products_id[] = (int)$result['product_id'];
$product_options = array();
if ($products_id) {
$filter_options = $this->model_catalog_filter->getOptionsByProductsId($products_id);
foreach ($filter_options as $product_id => $options) {
array_splice($options, $show_limit);
foreach($options as $option) {
if ($show_type == 'inline') {
$product_options[$product_id][] = $option['name'] . ': <b>' . $option['values'] . '</b>';
} else {
$product_options[$product_id][] = array(
'name' => $option['name'],
'values' => $option['values']
);
}
}
}
}
}
# end filter products attributes
вставить после:
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
# start filter products attributes
if ($show_type == 'inline') {
if (isset($product_options[$result['product_id']])) {
$attributes = implode(' / ', $product_options[$result['product_id']]);
} else {
$attributes = '';
}
} else {
if (isset($product_options[$result['product_id']])) {
$attributes = $product_options[$result['product_id']];
} else {
$attributes = array();
}
}
# end filter products attributes
вставить после:
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
# start filter products attributes
'attributes' => $attributes,
# end filter products attributes
11
catalog/controller/product/product.php
вставить после:
заменить:
$this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
# start filter
$this->load->model('catalog/filter');
# end filter
заменить:
$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
# start filter products attributes
$this->data['attribute_groups'] = array();
$product_options = array();
$filter_options = $this->model_catalog_filter->getOptionsByProductsId(array($this->request->get['product_id']));
if ($filter_options) {
foreach ($filter_options as $product_id => $options) {
foreach($options as $option) {
if (isset($option['values']) && $option['values']) {
$this->data['attribute_groups'][] = array(
'name' => '',
'attribute' => array(array(
'name' => $option['name'],
'text' => $option['values']
))
);
}
}
}
}
# end filter products attributes
12
catalog/controller/product/search.php
вставить перед:
вставить после:
вставить после:
вставить после:
$this->load->model('catalog/product');
# start filter
$this->load->model('catalog/filter');
# end filter
вставить после:
$results = $this->model_catalog_product->getProducts($data);
# start filter products attributes
$filter_module = $this->config->get('filter_module');
if (isset($filter_module[0])) {
$filter_settings = $filter_module[0];
$show_type = $filter_settings['pco_show_type'];
$show_limit = (int)$filter_settings['pco_show_limit'];
$products_id = array();
foreach ($results as $result) $products_id[] = (int)$result['product_id'];
$product_options = array();
if ($products_id) {
$filter_options = $this->model_catalog_filter->getOptionsByProductsId($products_id);
foreach ($filter_options as $product_id => $options) {
array_splice($options, $show_limit);
foreach($options as $option) {
if ($show_type == 'inline') {
$product_options[$product_id][] = $option['name'] . ': <b>' . $option['values'] . '</b>';
} else {
$product_options[$product_id][] = array(
'name' => $option['name'],
'values' => $option['values']
);
}
}
}
}
}
# end filter products attributes
вставить после:
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
# start filter products attributes
if ($show_type == 'inline') {
if (isset($product_options[$result['product_id']])) {
$attributes = implode(' / ', $product_options[$result['product_id']]);
} else {
$attributes = '';
}
} else {
if (isset($product_options[$result['product_id']])) {
$attributes = $product_options[$result['product_id']];
} else {
$attributes = array();
}
}
# end filter products attributes
вставить после:
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
# start filter products attributes
'attributes' => $attributes,
# end filter products attributes
13
catalog/controller/product/special.php
вставить перед:
вставить после:
вставить после:
вставить после:
$this->load->model('catalog/product');
# start filter
$this->load->model('catalog/filter');
# end filter
вставить после:
$results = $this->model_catalog_product->getProductSpecials($data);
# start filter products attributes
$filter_module = $this->config->get('filter_module');
if (isset($filter_module[0])) {
$filter_settings = $filter_module[0];
$show_type = $filter_settings['pco_show_type'];
$show_limit = (int)$filter_settings['pco_show_limit'];
$products_id = array();
foreach ($results as $result) $products_id[] = (int)$result['product_id'];
$product_options = array();
if ($products_id) {
$filter_options = $this->model_catalog_filter->getOptionsByProductsId($products_id);
foreach ($filter_options as $product_id => $options) {
array_splice($options, $show_limit);
foreach($options as $option) {
if ($show_type == 'inline') {
$product_options[$product_id][] = $option['name'] . ': <b>' . $option['values'] . '</b>';
} else {
$product_options[$product_id][] = array(
'name' => $option['name'],
'values' => $option['values']
);
}
}
}
}
}
# end filter products attributes
вставить после:
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
# start filter products attributes
if ($show_type == 'inline') {
if (isset($product_options[$result['product_id']])) {
$attributes = implode(' / ', $product_options[$result['product_id']]);
} else {
$attributes = '';
}
} else {
if (isset($product_options[$result['product_id']])) {
$attributes = $product_options[$result['product_id']];
} else {
$attributes = array();
}
}
# end filter products attributes
вставить после:
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
# start filter products attributes
'attributes' => $attributes,
# end filter products attributes
model
14
catalog/model/catalog/product.php
вставить перед:
вставить перед:
$sql .= " GROUP BY p.product_id";
# Start filter
if (!empty($data['filter_params'])) {
if ($this->registry->has('filter_sql') && $this->registry->get('filter_sql')) {
$sql .= $this->registry->get('filter_sql');
$this->registry->set('filter_sql', false);
} else {
return array();
}
}
# End filter
вставить перед:
$query = $this->db->query($sql);
return $query->row['total'];
# Start filter
if (!empty($data['filter_params'])) {
$this->load->model('catalog/filter');
$filter = $this->model_catalog_filter->getFilterQuery($data['filter_params']);
if ($filter) {
$sql .= $filter;
$this->registry->set('filter_sql', $filter);
} else {
return 0;
}
}
# End filter
view
15
catalog/view/theme/ваша_тема/template/product/category.tpl
заменить:
<div class="description"><?php echo $product['description']; ?></div>
<div class="description">
<!-- Product Filter start -->
<?php if ($product['attributes']) { ?>
<?php if (is_array($product['attributes'])) { ?>
<?php foreach ($product['attributes'] as $key => $attribute) { ?>
<?php if (!($key%3)) { ?><?php if ($key) { ?></ul><?php } ?><ul class="attributes"><?php } ?>
<li><span class="option"><?php echo $attribute['name']; ?>:</span> <span class="value"><?php echo $attribute['values']; ?></span></li>
<?php if ($key+1 == count($product['attributes'])) { ?></ul><?php } ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['attributes']; ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['description']; ?>
<?php } ?>
<div class="clear"></div>
<!-- Product Filter end -->
</div>
16
catalog/view/theme/ваша_тема/template/product/manufacturer_info.tpl
заменить:
<div class="description"><?php echo $product['description']; ?></div>
<div class="description">
<!-- Product Filter start -->
<?php if ($product['attributes']) { ?>
<?php if (is_array($product['attributes'])) { ?>
<?php foreach ($product['attributes'] as $key => $attribute) { ?>
<?php if (!($key%3)) { ?><?php if ($key) { ?></ul><?php } ?><ul class="attributes"><?php } ?>
<li><span class="option"><?php echo $attribute['name']; ?>:</span> <span class="value"><?php echo $attribute['values']; ?></span></li>
<?php if ($key+1 == count($product['attributes'])) { ?></ul><?php } ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['attributes']; ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['description']; ?>
<?php } ?>
<div class="clear"></div>
<!-- Product Filter end -->
</div>
17
catalog/view/theme/ваша_тема/template/product/search.tpl
заменить:
<div class="description"><?php echo $product['description']; ?></div>
<div class="description">
<!-- Product Filter start -->
<?php if ($product['attributes']) { ?>
<?php if (is_array($product['attributes'])) { ?>
<?php foreach ($product['attributes'] as $key => $attribute) { ?>
<?php if (!($key%3)) { ?><?php if ($key) { ?></ul><?php } ?><ul class="attributes"><?php } ?>
<li><span class="option"><?php echo $attribute['name']; ?>:</span> <span class="value"><?php echo $attribute['values']; ?></span></li>
<?php if ($key+1 == count($product['attributes'])) { ?></ul><?php } ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['attributes']; ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['description']; ?>
<?php } ?>
<div class="clear"></div>
<!-- Product Filter end -->
</div>
18
catalog/view/theme/ваша_тема/template/product/special.tpl
заменить:
<div class="description"><?php echo $product['description']; ?></div>
<div class="description">
<!-- Product Filter start -->
<?php if ($product['attributes']) { ?>
<?php if (is_array($product['attributes'])) { ?>
<?php foreach ($product['attributes'] as $key => $attribute) { ?>
<?php if (!($key%3)) { ?><?php if ($key) { ?></ul><?php } ?><ul class="attributes"><?php } ?>
<li><span class="option"><?php echo $attribute['name']; ?>:</span> <span class="value"><?php echo $attribute['values']; ?></span></li>
<?php if ($key+1 == count($product['attributes'])) { ?></ul><?php } ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['attributes']; ?>
<?php } ?>
<?php } else { ?>
<?php echo $product['description']; ?>
<?php } ?>
<div class="clear"></div>
<!-- Product Filter end -->
</div>