<?xml version="1.0" encoding="utf-8"?>
<modification>
    <code>plaza_control_panel</code>
    <name>Plaza Control Panel</name>
    <version>18.12.27</version>
    <author>Plaza Themes</author>

    <!-- Menu Left in Admin -->
    <file path="admin/controller/common/column_left.php">
        <operation>
            <search ><![CDATA[$catalog = array();]]></search>
            <add position="before"><![CDATA[
            $this->load->language('plaza/adminmenu');

            if($this->user->hasPermission('access', 'extension/module/ptcontrolpanel')) {
                $data['menus'][] = array(
                    'id'       => 'plaza-dashboard',
                    'icon'     => 'fa-plaza',
                    'name'     => $this->language->get('text_theme_dashboard'),
                    'href'     => $this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true)
                );
            }
            ]]></add>
        </operation>
    </file>

    <!-- PRODUCT CONFIGURATION -->
    <file path="admin/controller/catalog/product.php"> <!-- Done -->
        <operation>
            <search ><![CDATA[public function index() {]]></search>
            <add position="after"><![CDATA[
        $this->load->model('plaza/controlpanel');
        $this->model_plaza_controlpanel->setupRotateImage();
        $this->model_plaza_controlpanel->setupColorSwatches();
            ]]></add>
        </operation>
        <operation>
            <search ><![CDATA[$this->load->language('catalog/product');]]></search>
            <add position="before"><![CDATA[
                $this->load->language('plaza/rotateimage');
                $this->load->language('extension/module/ptcontrolpanel');
            ]]></add>
        </operation>
        <operation>
            <search ><![CDATA['sort_order' => $product_image['sort_order']]]></search>
            <add position="before"><![CDATA[
                'is_rotate' => $product_image['is_rotate'],
                'product_option_value_id' => $product_image['product_option_value_id'],
            ]]></add>
        </operation>
    </file>

    <file path="admin/model/catalog/product.php"> <!-- Done -->
        <operation>
            <search><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");]]></search>
            <add position="replace">
                <![CDATA[
                    if(isset($product_image['product_option_value_id']) && $product_image['product_option_value_id']) {
                        $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "', is_rotate = '" . (int)$product_image['is_rotate'] . "', product_option_value_id = '" . (int)$product_image['product_option_value_id'] . "'");
                    } else {
                        $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "', is_rotate = '" . (int)$product_image['is_rotate'] . "'");
                    }
                ]]>
            </add>
        </operation>
    </file>

    <file path="admin/view/template/catalog/product_form.twig"> <!-- Done -->
        <operation>
            <search><![CDATA[<td class="text-right">{{ entry_sort_order }}</td>]]></search>
            <add position="after">
                <![CDATA[
                    <td class="text-center">{{ entry_option }}</td>
                    <td class="text-center">{{ entry_rotate }}</td>
                ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[<td class="text-left"><button type="button" onclick="$('#image-row{{ image_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>]]></search>
            <add position="before">
                <![CDATA[
                    <!-- Swatches Options -->
                    <td class="text-center">
                      <select class="form-control image-opt" id="product-image-option-{{ image_row }}" data-row="{{ image_row }}" style="margin-bottom: 10px;">
                        <option value="0">{{ text_choose_option }}</option>
                        {% for product_option in product_options %}
                          {% if product_option.type == "select" or product_option.type == "radio" %}
                            <option value="{{ product_option.product_option_id }}">{{ product_option.name }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% for product_option in product_options %}
                        {% if product_option.type == "select" or product_option.type == "radio" %}
                        <select class="form-control image-opt-value" id="product-image-option-{{ image_row }}-{{ product_option.product_option_id }}" data-row="{{ image_row }}" data-type="{{ product_option.product_option_id }}">
                          <option value="0">{{ text_choose_value }}</option>
                          {% for po_value in product_option.product_option_value %}
                            {% if option_values[product_option.option_id] %}
                              {% for option_value in option_values[product_option.option_id] %}
                                {% if option_value.option_value_id == po_value.option_value_id %}
                                  <option value="{{ po_value.product_option_value_id }}" {% if product_image.product_option_value_id == po_value.product_option_value_id %} selected="selected" {% endif %}>{{ option_value.name }}</option>
                                {% endif %}
                              {% endfor %}
                            {% endif %}
                          {% endfor %}
                        </select>
                        {% endif %}
                      {% endfor %}
                    </td>

                    <!-- Rotate Image -->
                    <td class="text-center">
                      <select name="product_image[{{ image_row }}][is_rotate]" class="form-control rotate-select">
                        {% if product_image.is_rotate and (product_image.is_rotate == 1) %}
                        <option value="1" selected="selected">Yes</option>
                        <option value="0">No</option>
                        {% else %}
                        <option value="1">Yes</option>
                        <option value="0" selected="selected">No</option>
                        {% endif %}
                      </select>
                    </td>
                    <!-- End -->
                ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[function addImage() {]]></search>
            <add position="before">
                <![CDATA[
                    $('#tab-image tfoot td:first').attr('colspan', 4);

                    // Swatches Options
                    $('.image-opt-value').hide();
                    $('.image-opt-value').each(function () {
                      var row = $(this).data('row');
                      $(this).find('option').each(function () {
                        if($(this).attr("selected") == 'selected') {
                          var option_id = $(this).closest('.image-opt-value').data('type');
                          $('#product-image-option-' + row).find("option[value='" + option_id + "']").attr('selected', 'selected');
                          $(this).closest('.image-opt-value').attr('name', 'product_image[' + row + '][product_option_value_id]').show();
                        }
                      });
                    });

                    $('.image-opt').change(function () {
                      var row = $(this).data('row');
                      var id_select = $(this).attr('id');
                      var product_option_id = $(this).val();
                      $('#image-row' + row).find('.image-opt-value').removeAttr('name').hide();
                      $('#' + id_select + "-" + product_option_id).attr('name', 'product_image[' + row + '][product_option_value_id]').show();
                    });

                    $('.rotate-select').change(function() {
                      var value = $(this).val();
                      if(value == 1) {
                        $('.rotate-select').val(0);
                        $(this).val(1);
                      }
                    });
                ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[$('#images tbody').append(html);]]></search>
            <add position="after">
                <![CDATA[
                    // Swatches Options
                    $('.image-opt').change(function () {
                      var row = $(this).data('row');
                      var id_select = $(this).attr('id');
                      var product_option_id = $(this).val();
                      $('#image-row' + row).find('.image-opt-value').removeAttr('name').hide();
                      $('#' + id_select + "-" + product_option_id).attr('name', 'product_image[' + row + '][product_option_value_id]').show();
                    });

                    $('.rotate-select').change(function() {
                      var value = $(this).val();
                      if(value == 1) {
                        $('.rotate-select').val(0);
                        $(this).val(1);
                      }
                    });
                    //End
                ]]>
            </add>
        </operation>
        <operation>
            <search><![CDATA[html += '  <td class="text-left"><button type="button" onclick="$(\'#image-row' + image_row  + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';]]></search>
            <add position="before">
                <![CDATA[
                    // Swatches Options
                    html += '  <td class="text-center">';
                    html += '    <select class="form-control image-opt" id="product-image-option-' + image_row + '" data-row="' + image_row + '" style="margin-bottom: 10px;">';
                    html += '       <option value="0">{{ text_choose_option }}</option>';
                    {% for product_option in product_options %}
                    {% if product_option.type == "select" or product_option.type == "radio" %}
                    html += '       <option value="{{ product_option.product_option_id }}">{{ product_option.name }}</option>';
                    {% endif %}
                    {% endfor %}
                    html += '    </select>';
                    {% for product_option in product_options %}
                    {% if product_option.type == "select" or product_option.type == "radio" %}
                    html += '    <select class="form-control image-opt-value" id="product-image-option-' + image_row + '-{{ product_option.product_option_id }}" data-row="' + image_row + '" data-type="{{ product_option.product_option_id }}" style="display: none;">';
                    html += '       <option value="0">{{ text_choose_value }}</option>';
                    {% for po_value in product_option.product_option_value %}
                    {% if option_values[product_option.option_id] %}
                    {% for option_value in option_values[product_option.option_id] %}
                    {% if option_value.option_value_id == po_value.option_value_id %}
                    html += '       <option value="{{ po_value.product_option_value_id }}">{{ option_value.name }}</option>';
                    {% endif %}
                    {% endfor %}
                    {% endif %}
                    {% endfor %}
                    html += '    </select>';
                    {% endif %}
                    {% endfor %}
                    html += '  </td>';

                    html += ' <td class="text-center">';
                    html += '   <select name="product_image[' + image_row + '][is_rotate]" class="form-control rotate-select">';
                    html += '     <option value="1">{{ text_yes }}</option>';
                    html += '     <option value="0" selected="selected">{{ text_no }}</option>';
                    html += '   </select>';
                    html += ' </td>';
                ]]>
            </add>
        </operation>
    </file>

    <file path="catalog/controller/product/product.php"> <!-- Done -->
        <operation>
            <search><![CDATA[$data['heading_title'] = $product_info['name'];]]></search>
            <add position="before"><![CDATA[
            /* Plaza Product Configuration */
            $this->load->model('tool/image');
            $store_id = $this->config->get('config_store_id');

            /* Catalog Mode */
            if(isset($this->config->get('module_ptcontrolpanel_product_price')[$store_id])) {
                $data['show_product_price'] = (int) $this->config->get('module_ptcontrolpanel_product_price')[$store_id];
            } else {
                $data['show_product_price'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_product_cart')[$store_id])) {
                $data['show_product_button_cart'] = (int) $this->config->get('module_ptcontrolpanel_product_cart')[$store_id];
            } else {
                $data['show_product_button_cart'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_product_wishlist')[$store_id])) {
                $data['show_product_button_wishlist'] = (int) $this->config->get('module_ptcontrolpanel_product_wishlist')[$store_id];
            } else {
                $data['show_product_button_wishlist'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_product_compare')[$store_id])) {
                $data['show_product_button_compare'] = (int) $this->config->get('module_ptcontrolpanel_product_compare')[$store_id];
            } else {
                $data['show_product_button_compare'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_product_options')[$store_id])) {
                $data['show_product_options'] = (int) $this->config->get('module_ptcontrolpanel_product_options')[$store_id];
            } else {
                $data['show_product_options'] = 0;
            }

            /* Product Details */
            if(isset($this->config->get('module_ptcontrolpanel_related')[$store_id])) {
                $data['show_product_related'] = (int) $this->config->get('module_ptcontrolpanel_related')[$store_id];
            } else {
                $data['show_product_related'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_social')[$store_id])) {
                $data['show_product_social'] = (int) $this->config->get('module_ptcontrolpanel_social')[$store_id];
            } else {
                $data['show_product_social'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_tax')[$store_id])) {
                $data['show_product_tax'] = (int) $this->config->get('module_ptcontrolpanel_tax')[$store_id];
            } else {
                $data['show_product_tax'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_tags')[$store_id])) {
                $data['show_product_tags'] = (int) $this->config->get('module_ptcontrolpanel_tags')[$store_id];
            } else {
                $data['show_product_tags'] = 0;
            }

            $use_zoom = (int) $this->config->get('module_ptcontrolpanel_use_zoom')[$store_id];

            if($use_zoom) {
                $data['use_zoom'] = true;

                if ($product_info['image']) {
                    $data['small_image'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'));
                } else {
                    $data['small_image'] = '';
                }

                $data['popup_dimension'] = array(
                    'width' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'),
                    'height' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')
                );

                $data['thumb_dimension'] = array(
                    'width' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'),
                    'height' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height')
                );

                $data['small_dimension'] = array(
                    'width' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'),
                    'height' => $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height')
                );

                if(isset($this->config->get('module_ptcontrolpanel_zoom_type')[$store_id])) {
                    $zoom_type = $this->config->get('module_ptcontrolpanel_zoom_type')[$store_id];
                } else {
                    $zoom_type = 'outer';
                }

                if(isset($this->config->get('module_ptcontrolpanel_zoom_space')[$store_id])) {
                    $zoom_space = $this->config->get('module_ptcontrolpanel_zoom_space')[$store_id];
                } else {
                    $zoom_space = '0';
                }

                if(isset($this->config->get('module_ptcontrolpanel_zoom_title')[$store_id])) {
                    $zoom_title = (int) $this->config->get('module_ptcontrolpanel_zoom_title')[$store_id];
                } else {
                    $zoom_title = 0;
                }

                $data['product_zoom_settings'] = array(
                    'type' => $zoom_type,
                    'space' => $zoom_space,
                    'title' => $zoom_title
                );

                if (file_exists('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/product/zoom.css')) {
                    $this->document->addStyle('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/product/zoom.css');
                } else {
                    $this->document->addStyle('catalog/view/theme/default/stylesheet/plaza/product/zoom.css');
                }

                $this->document->addStyle('catalog/view/javascript/jquery/swiper/css/swiper.min.css');
                
                $this->document->addScript('catalog/view/javascript/jquery/swiper/js/swiper.jquery.js');
                $this->document->addStyle('catalog/view/javascript/plaza/cloudzoom/css/cloud-zoom.css');
                $this->document->addScript('catalog/view/javascript/plaza/cloudzoom/cloud-zoom.1.0.2.min.js');
                $this->document->addScript('catalog/view/javascript/plaza/cloudzoom/zoom.js');
            } else {
                $data['use_zoom'] = false;
            }

            $use_swatches = (int) $this->config->get('module_ptcontrolpanel_use_swatches')[$store_id];

            if($use_swatches) {
                $data['use_swatches'] = true;
                $data['icon_swatches_width'] = $this->config->get('module_ptcontrolpanel_swatches_width')[$store_id];
                $data['icon_swatches_height'] = $this->config->get('module_ptcontrolpanel_swatches_height')[$store_id];
                $data['swatches_option'] = $this->config->get('module_ptcontrolpanel_swatches_option')[$store_id];

                if (file_exists('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/swatches/swatches.css')) {
                    $this->document->addStyle('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/swatches/swatches.css');
                } else {
                    $this->document->addStyle('catalog/view/theme/default/stylesheet/plaza/swatches/swatches.css');
                }

                $this->document->addScript('catalog/view/javascript/plaza/swatches/swatches.js');
            } else {
                $data['use_swatches'] = false;
            }
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[$data['images'][] = array(]]></search>
            <add position="after"><![CDATA[
                    'product_option_value_id' => $result['product_option_value_id'],
                    'product_image_option' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height')),
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[if ((float)$product_info['special']) {]]></search>
            <add position="after"><![CDATA[
                $this->load->model('plaza/catalog');

				$product_plaza_info = $this->model_plaza_catalog->getProduct($data['product_id']);

				if (isset($product_plaza_info['date_start']) && $product_plaza_info['date_start']) {
					if($product_plaza_info['date_start'] != '0000-00-00') {
						$data['date_start'] = $product_plaza_info['date_start'];
					} else {
						$data['date_start'] = false;
					}
					
				} else {
					$data['date_start'] = false;
				}

				if(isset($product_plaza_info['date_end']) &&  $product_plaza_info['date_end']) {
					if($product_plaza_info['date_end'] != '0000-00-00') {
						$data['date_end'] = $product_plaza_info['date_end'];
					} else {
						$data['date_end'] = false;
					}
				} else {
					$data['date_end'] = false;
				}

				if($data['date_start'] && $data['date_end']) {
					$this->document->addScript('catalog/view/javascript/plaza/countdown/countdown.js');
				}
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[$data['special'] = false;]]></search>
            <add position="after"><![CDATA[
                $data['date_start'] = false;
				$data['date_end'] = false;
            ]]></add>
        </operation>
    </file>
    
    <!-- CATEGORY CONFIGURATION -->
    <file path="catalog/controller/product/category.php">
        <operation>
            <search><![CDATA[$data['heading_title'] = $category_info['name'];]]></search>
            <add position="before"><![CDATA[
            /* Plaza Category Configuration */
            $store_id = $this->config->get('config_store_id');

            /* Catalog Mode */
            if(isset($this->config->get('module_ptcontrolpanel_category_price')[$store_id])) {
                $data['show_cate_price'] = (int) $this->config->get('module_ptcontrolpanel_category_price')[$store_id];
            } else {
                $data['show_cate_price'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_cart')[$store_id])) {
                $data['show_cate_cart'] = (int) $this->config->get('module_ptcontrolpanel_category_cart')[$store_id];
            } else {
                $data['show_cate_cart'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_wishlist')[$store_id])) {
                $data['show_cate_wishlist'] = (int) $this->config->get('module_ptcontrolpanel_category_wishlist')[$store_id];
            } else {
                $data['show_cate_wishlist'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_compare')[$store_id])) {
                $data['show_cate_compare'] = (int) $this->config->get('module_ptcontrolpanel_category_compare')[$store_id];
            } else {
                $data['show_cate_compare'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_prodes')[$store_id])) {
                $data['show_cate_prodes'] = (int) $this->config->get('module_ptcontrolpanel_category_prodes')[$store_id];
            } else {
                $data['show_cate_prodes'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_label')[$store_id])) {
                $data['show_cate_label'] = (int) $this->config->get('module_ptcontrolpanel_category_label')[$store_id];
            } else {
                $data['show_cate_label'] = 0;
            }

            /* Category Settings */
            if(isset($this->config->get('module_ptcontrolpanel_category_image')[$store_id])) {
                $data['show_cate_img'] = (int) $this->config->get('module_ptcontrolpanel_category_image')[$store_id];
            } else {
                $data['show_cate_img'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_category_description')[$store_id])) {
                $data['show_cate_des'] = (int) $this->config->get('module_ptcontrolpanel_category_description')[$store_id];
            } else {
                $data['show_cate_des'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_sub_category')[$store_id])) {
                $data['show_cate_sub'] = (int) $this->config->get('module_ptcontrolpanel_sub_category')[$store_id];
            } else {
                $data['show_cate_sub'] = 0;
            }

            if(isset($this->config->get('module_ptcontrolpanel_use_filter')[$store_id])) {
                $data['use_filter'] = (int) $this->config->get('module_ptcontrolpanel_use_filter')[$store_id];
            } else {
                $data['use_filter'] = 0;
            }

            if (!empty($_SERVER['HTTPS'])) {
                // SSL connection
                $common_url = str_replace('http://', 'https://', $this->config->get('config_url'));
            } else {
                $common_url = $this->config->get('config_url');
            }

            $data['pt_sorts'] = array();

            $data['pt_limits'] = array();

            if($data['use_filter']) {
                
				
				$this->document->addStyle('catalog/view/javascript/jquery/css/jquery-ui.css');
				if (file_exists('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/category/filter.css')) {
                    $this->document->addStyle('catalog/view/theme/' . $this->config->get('theme_' . $this->config->get('config_theme') . '_directory') . '/stylesheet/plaza/category/filter.css');
                } else {
                    $this->document->addStyle('catalog/view/theme/default/stylesheet/plaza/category/filter.css');
                }
				$this->document->addScript('catalog/view/javascript/jquery/jquery-ui.js');	
                $this->document->addScript('catalog/view/javascript/plaza/category/filter.js');

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_default'),
                    'value' => 'p.sort_order-ASC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=p.sort_order&order=ASC' . $url
                );

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_name_asc'),
                    'value' => 'pd.name-ASC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=pd.name&order=ASC' . $url
                );

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_name_desc'),
                    'value' => 'pd.name-DESC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=pd.name&order=DESC' . $url
                );

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_price_asc'),
                    'value' => 'p.price-ASC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=p.price&order=ASC' . $url
                );

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_price_desc'),
                    'value' => 'p.price-DESC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=p.price&order=DESC' . $url
                );

                if ($this->config->get('config_review_status')) {
                    $data['pt_sorts'][] = array(
                        'text'  => $this->language->get('text_rating_desc'),
                        'value' => 'rating-DESC',
                        'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=rating&order=DESC' . $url
                    );

                    $data['pt_sorts'][] = array(
                        'text'  => $this->language->get('text_rating_asc'),
                        'value' => 'rating-ASC',
                        'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=rating&order=ASC' . $url
                    );
                }

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_model_asc'),
                    'value' => 'p.model-ASC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=p.model&order=ASC' . $url
                );

                $data['pt_sorts'][] = array(
                    'text'  => $this->language->get('text_model_desc'),
                    'value' => 'p.model-DESC',
                    'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . '&sort=p.model&order=DESC' . $url
                );

                $data['pt_limits'] = array();

                $limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));

                sort($limits);

                foreach($limits as $value) {
                    $data['pt_limits'][] = array(
                        'text'  => $value,
                        'value' => $value,
                        'href'  => $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . $url . '&limit=' . $value
                    );
                }

                if(isset($this->config->get('module_ptcontrolpanel_loader_img')[$store_id])) {
                    $data['loader_img'] = $common_url . 'image/' . $this->config->get('module_ptcontrolpanel_loader_img')[$store_id];
                } else {
                    $data['loader_img'] = $common_url . 'image/plaza/ajax-loader.gif';;
                }
            }

            if(isset($this->config->get('module_ptcontrolpanel_cate_quickview')[$store_id])) {
	            $data['use_quick_view'] = (int) $this->config->get('module_ptcontrolpanel_cate_quickview')[$store_id];
	        } else {
	            $data['use_quick_view'] = 0;
	        }

	        if(isset($this->config->get('module_ptcontrolpanel_img_effect')[$store_id])) {
                $data['image_effect'] = $this->config->get('module_ptcontrolpanel_img_effect')[$store_id];
            } else {
                $data['image_effect'] = false;
            }

            if($data['image_effect'] == 'swatches') {
                $this->document->addScript('catalog/view/javascript/plaza/swatches/swatches.js');
            }

            if(isset($this->config->get('module_ptcontrolpanel_advance_view')[$store_id])) {
                $data['use_advance_view'] = (int) $this->config->get('module_ptcontrolpanel_advance_view')[$store_id];
            } else {
                $data['use_advance_view'] = 0;
            }

            if($data['use_advance_view']) {
                $this->document->addScript('catalog/view/javascript/plaza/category/grid.js');
            }

            if(isset($this->config->get('module_ptcontrolpanel_default_view')[$store_id])) {
                $data['advance_default_view'] = $this->config->get('module_ptcontrolpanel_default_view')[$store_id];
            } else {
                $data['advance_default_view'] = false;
            }

            if(isset($this->config->get('module_ptcontrolpanel_product_row')[$store_id])) {
                $data['product_p_row'] = $this->config->get('module_ptcontrolpanel_product_row')[$store_id];
            } else {
                $data['product_p_row'] = false;
            }
			$new_results = $this->model_catalog_product->getLatestProducts(10);
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[$data['products'][] = array(]]></search>
            <add position="before"><![CDATA[
                if($data['image_effect'] == 'hover') {
                    $this->load->model('plaza/rotateimage');

                    $product_rotate_image = $this->model_plaza_rotateimage->getProductRotateImage($result['product_id']);

                    if($product_rotate_image) {
                        $rotate_image = $this->model_tool_image->resize($product_rotate_image, $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
                    } else {
                        $rotate_image = false;
                    }
                } else {
                    $rotate_image = false;
                }

                $swatches_images = array();

                $options = array();

                if($data['image_effect'] == 'swatches') {
                    $data['icon_swatches_width'] = $this->config->get('module_ptcontrolpanel_cate_swatches_width')[$store_id];
                    $data['icon_swatches_height'] = $this->config->get('module_ptcontrolpanel_cate_swatches_height')[$store_id];

                    $this->load->model('plaza/swatches');

                    $images = $this->model_catalog_product->getProductImages($result['product_id']);

                    $is_swatches = false;

                    foreach ($images as $img) {
                        if ($img['product_option_value_id']) {
                            $image_option_id = $this->model_plaza_swatches->getOptionIdByProductOptionValueId($img['product_option_value_id']);

                            if($image_option_id == $this->config->get('module_ptcontrolpanel_swatches_option')[$store_id]) {
                                $is_swatches = true;

                                $swatches_images[] = array(
                                    'product_option_value_id' => $img['product_option_value_id'],
                                    'image' => $this->model_tool_image->resize($img['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'))
                                );
                            }
                        }
                    }

                    if($is_swatches) {
                        foreach ($this->model_catalog_product->getProductOptions($result['product_id']) as $option) {
                            if($option['option_id'] == $this->config->get('module_ptcontrolpanel_swatches_option')[$store_id]) {
                                $product_option_value_data = array();

                                foreach ($option['product_option_value'] as $option_value) {
                                    if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
                                        $product_option_value_data[] = array(
                                            'product_option_value_id' => $option_value['product_option_value_id'],
                                            'option_value_id'         => $option_value['option_value_id'],
                                            'name'                    => $option_value['name'],
                                            'image'                   => $this->model_tool_image->resize($option_value['image'], $data['icon_swatches_width'], $data['icon_swatches_height']),
                                        );
                                    }
                                }

                                $options[] = array(
                                    'product_option_id'    => $option['product_option_id'],
                                    'product_option_value' => $product_option_value_data,
                                    'option_id'            => $option['option_id'],
                                    'name'                 => $option['name'],
                                    'type'                 => $option['type'],
                                    'value'                => $option['value'],
                                );
                            }
                        }
                    }
                }
				$is_new = false;
				if ($new_results) {
					foreach($new_results as $new_r) {
						if($result['product_id'] == $new_r['product_id']) {
							$is_new = true;
						}
					}
				}
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[$data['products'][] = array(]]></search>
            <add position="after"><![CDATA[
                    'options' => $options,
                    'swatches_images' => $swatches_images,
                    'rotate_image' => $rotate_image,
					'is_new'        => $is_new,
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[$pagination = new Pagination();]]></search>
            <add position="before"><![CDATA[
            $pt_pagination = new Pagination();
            $pt_pagination->total = $product_total;
            $pt_pagination->page = $page;
            $pt_pagination->limit = $limit;
            $pt_pagination->url = $common_url . 'index.php?route=plaza/filter/category&path=' . $category_id . $url . '&page={page}';

            $data['pt_pagination'] = $pt_pagination->render();
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/column_left.php">
    	<operation>
            <search><![CDATA[if ($route == 'product/category' && isset($this->request->get['path'])) {]]></search>
            <add position="before"><![CDATA[
       	if ($route == 'product/category') {
			$store_id = $this->config->get('config_store_id');

			if(isset($this->config->get('module_ptcontrolpanel_use_filter')[$store_id])) {
				$use_filter = (int) $this->config->get('module_ptcontrolpanel_use_filter')[$store_id];
			} else {
				$use_filter = 0;
			}

			if(isset($this->config->get('module_ptcontrolpanel_filter_position')[$store_id])) {
				$filter_position = $this->config->get('module_ptcontrolpanel_filter_position')[$store_id];
			} else {
				$filter_position = false;
			}

			if($use_filter && $filter_position == 'left') {
				$data['use_filter'] = true;
			} else {
				$data['use_filter'] = false;
			}

			if($data['use_filter']) {
				$data['filter_section'] = $this->load->controller('plaza/filter');
			}
		} else {
			$data['use_filter'] = false;
		}
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/column_right.php">
    	<operation>
            <search><![CDATA[if ($route == 'product/category' && isset($this->request->get['path'])) {]]></search>
            <add position="before"><![CDATA[
       	if ($route == 'product/category') {
			$store_id = $this->config->get('config_store_id');

			if(isset($this->config->get('module_ptcontrolpanel_use_filter')[$store_id])) {
				$use_filter = (int) $this->config->get('module_ptcontrolpanel_use_filter')[$store_id];
			} else {
				$use_filter = 0;
			}

			if(isset($this->config->get('module_ptcontrolpanel_filter_position')[$store_id])) {
				$filter_position = $this->config->get('module_ptcontrolpanel_filter_position')[$store_id];
			} else {
				$filter_position = false;
			}

			if($use_filter && $filter_position == 'right') {
				$data['use_filter'] = true;
			} else {
				$data['use_filter'] = false;
			}

			if($data['use_filter']) {
				$data['filter_section'] = $this->load->controller('plaza/filter');
			}
		} else {
			$data['use_filter'] = false;
		}

            ]]></add>
        </operation>
    </file>

    <file path="catalog/model/catalog/product.php">
        <operation>
            <search><![CDATA[if (!empty($data['filter_manufacturer_id'])) {]]></search>
            <add position="before">
                <![CDATA[
        /* Price range */
        if  (!empty($data['filter_price'])) {
            $min_price = $data['filter_price']['min_price'];
            $max_price = $data['filter_price']['max_price'];
            $sql_sl_special = "(SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1)";
            $sql_sl_discount = "(SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1)";
            $sql .= " AND (CASE WHEN " . $sql_sl_special . " IS NOT NULL THEN " . $sql_sl_special . " WHEN " . $sql_sl_discount . " IS NOT NULL THEN ". $sql_sl_discount . " ELSE p.price END) >='". $min_price ."'" ;
            $sql .= " AND (CASE WHEN " . $sql_sl_special . " IS NOT NULL THEN " . $sql_sl_special . " WHEN " . $sql_sl_discount . " IS NOT NULL THEN ". $sql_sl_discount . " ELSE p.price END) <='". $max_price ."'";
        }
        /* End */
                ]]>
            </add>
        </operation>
    </file>

    <!-- Plaza THEME OPTION -->
    <file path="catalog/controller/common/header.php">
        <operation>
            <search><![CDATA[return $this->load->view('common/header', $data);]]></search>
            <add position="before"><![CDATA[
        $data['store_id'] = $this->config->get('config_store_id');
		$data['email'] = $this->config->get('config_email');
        /* General */
		if(isset($this->config->get('module_ptcontrolpanel_header_layout')[$data['store_id']])) {
            $data['header_layout'] = (int) $this->config->get('module_ptcontrolpanel_header_layout')[$data['store_id']];
        } else {
            $data['header_layout'] = 1;
        }
		
        /* Sticky Header */
        if(isset($this->config->get('module_ptcontrolpanel_sticky_header')[$data['store_id']])) {
            $data['sticky_header'] = (int) $this->config->get('module_ptcontrolpanel_sticky_header')[$data['store_id']];
        } else {
            $data['sticky_header'] = 0;
        }

        /* Scroll Top */
        if(isset($this->config->get('module_ptcontrolpanel_scroll_top')[$data['store_id']])) {
            $data['scroll_top'] = (int) $this->config->get('module_ptcontrolpanel_scroll_top')[$data['store_id']];
        } else {
            $data['scroll_top'] = 0;
        }

        /* Lazy Load */
        if(isset($this->config->get('module_ptcontrolpanel_lazy_load')[$data['store_id']])) {
            $data['lazy_load'] = (int) $this->config->get('module_ptcontrolpanel_lazy_load')[$data['store_id']];
        } else {
            $data['lazy_load'] = 0;
        }

        /* Catalog Mode */
        /* Header */
        if(isset($this->config->get('module_ptcontrolpanel_header_cart')[$data['store_id']])) {
            $data['header_cart'] = (int) $this->config->get('module_ptcontrolpanel_header_cart')[$data['store_id']];
        } else {
            $data['header_cart'] = 0;
        }

        if(isset($this->config->get('module_ptcontrolpanel_header_currency')[$data['store_id']])) {
            $data['header_currency'] = (int) $this->config->get('module_ptcontrolpanel_header_currency')[$data['store_id']];
        } else {
            $data['header_currency'] = 0;
        }

        if(isset($this->config->get('module_ptcontrolpanel_module_quickview')[$data['store_id']])) {
            $module_quick_view = (int) $this->config->get('module_ptcontrolpanel_module_quickview')[$data['store_id']];
        } else {
            $module_quick_view = 0;
        }

        if(isset($this->config->get('module_ptcontrolpanel_cate_quickview')[$data['store_id']])) {
            $category_quick_view = (int) $this->config->get('module_ptcontrolpanel_cate_quickview')[$data['store_id']];
        } else {
            $category_quick_view = 0;
        }

        if($module_quick_view || $category_quick_view) {
        	$data['use_quick_view'] = true;
        } else {
			$data['use_quick_view'] = false;
        }

        /* Advance */
        if(isset($this->config->get('module_ptcontrolpanel_custom_js')[$data['store_id']])) {
            $data['custom_js'] = $this->config->get('module_ptcontrolpanel_custom_js')[$data['store_id']];
        } else {
            $data['custom_js'] = false;
        }
        	]]></add>
        </operation>
        <operation>
            <search><![CDATA[$data['menu'] = $this->load->controller('common/menu');]]></search>
            <add position="after"><![CDATA[
                $data['header'] = $this->load->controller('plaza/header');
            ]]></add>
        </operation>
		<operation>
            <search><![CDATA[class ControllerCommonHeader extends Controller {]]></search>
            <add position="before"><![CDATA[
            require_once(DIR_SYSTEM . 'Mobile_Detect.php');
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[return $this->load->view('common/header', $data);]]></search>
            <add position="replace"><![CDATA[
        $detect = new Mobile_Detect;
		if ( $detect->isTablet() ) {
			return $this->load->view('common/header', $data);
		} else {
			if( $detect->isMobile()){
				return $this->load->view('plaza/page_section/header_mobile', $data);
			} else {
				return $this->load->view('common/header', $data);
			}
		}
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/column_left.php">
        <operation>
            <search><![CDATA[class ControllerCommonColumnLeft extends Controller {]]></search>
            <add position="before"><![CDATA[
            require_once(DIR_SYSTEM . 'Mobile_Detect.php');
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[$route = 'common/home';]]></search>
            <add position="replace"><![CDATA[
            $store_id = $this->config->get('config_store_id');

            if(isset($this->config->get('module_ptcontrolpanel_responsive_type')[$store_id])) {
                $responsive_type = $this->config->get('module_ptcontrolpanel_responsive_type')[$store_id];
            } else {
                $responsive_type = "";
            }

            if($responsive_type == "specified") {
                $detect = new Mobile_Detect;

                if ( $detect->isTablet() ) {
                    $route = 'common/home';
                } else {
                    if( $detect->isMobile()){
                        $route = 'plaza/responsive/mobile';
                    } else {
                        $route = 'common/home';
                    }
                }
            } else {
                $route = 'common/home';
            }
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[if (isset($this->request->get['route'])) {]]></search>
            <add position="replace"><![CDATA[
            if (isset($this->request->get['route']) && $this->request->get['route'] != "common/home") {
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/column_right.php">
        <operation>
            <search><![CDATA[class ControllerCommonColumnRight extends Controller {]]></search>
            <add position="before"><![CDATA[
            require_once(DIR_SYSTEM . 'Mobile_Detect.php');
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[if (isset($this->request->get['route'])) {]]></search>
            <add position="replace"><![CDATA[
            if (isset($this->request->get['route']) && $this->request->get['route'] != "common/home") {
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[$route = 'common/home';]]></search>
            <add position="replace"><![CDATA[
            $store_id = $this->config->get('config_store_id');

            if(isset($this->config->get('module_ptcontrolpanel_responsive_type')[$store_id])) {
                $responsive_type = $this->config->get('module_ptcontrolpanel_responsive_type')[$store_id];
            } else {
                $responsive_type = "";
            }

            if($responsive_type == "specified") {
                $detect = new Mobile_Detect;

                if ( $detect->isTablet() ) {
                    $route = 'common/home';
                } else {
                    if( $detect->isMobile()){
                        $route = 'plaza/responsive/mobile';
                    } else {
                        $route = 'common/home';
                    }
                }
            } else {
                $route = 'common/home';
            }
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/content_bottom.php">
        <operation>
            <search><![CDATA[class ControllerCommonContentBottom extends Controller {]]></search>
            <add position="before"><![CDATA[
            require_once(DIR_SYSTEM . 'Mobile_Detect.php');
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[if (isset($this->request->get['route'])) {]]></search>
            <add position="replace"><![CDATA[
            if (isset($this->request->get['route']) && $this->request->get['route'] != "common/home") {
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[$route = 'common/home';]]></search>
            <add position="replace"><![CDATA[
            $store_id = $this->config->get('config_store_id');

            if(isset($this->config->get('module_ptcontrolpanel_responsive_type')[$store_id])) {
                $responsive_type = $this->config->get('module_ptcontrolpanel_responsive_type')[$store_id];
            } else {
                $responsive_type = "";
            }

            if($responsive_type == "specified") {
                $detect = new Mobile_Detect;

                if ( $detect->isTablet() ) {
                    $route = 'common/home';
                } else {
                    if( $detect->isMobile()){
                        $route = 'plaza/responsive/mobile';
                    } else {
                        $route = 'common/home';
                    }
                }
            } else {
                $route = 'common/home';
            }
            ]]></add>
        </operation>
    </file>

    <file path="catalog/controller/common/content_top.php">
        <operation>
            <search><![CDATA[class ControllerCommonContentTop extends Controller {]]></search>
            <add position="before"><![CDATA[
            require_once(DIR_SYSTEM . 'Mobile_Detect.php');
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[if (isset($this->request->get['route'])) {]]></search>
            <add position="replace"><![CDATA[
            if (isset($this->request->get['route']) && $this->request->get['route'] != "common/home") {
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[$route = 'common/home';]]></search>
            <add position="replace"><![CDATA[
            $store_id = $this->config->get('config_store_id');

            if(isset($this->config->get('module_ptcontrolpanel_responsive_type')[$store_id])) {
                $responsive_type = $this->config->get('module_ptcontrolpanel_responsive_type')[$store_id];
            } else {
                $responsive_type = "";
            }

            if($responsive_type == "specified") {
                $detect = new Mobile_Detect;

                if ( $detect->isTablet() ) {
                    $route = 'common/home';
                } else {
                    if( $detect->isMobile()){
                        $route = 'plaza/responsive/mobile';
                    } else {
                        $route = 'common/home';
                    }
                }
            } else {
                $route = 'common/home';
            }
            ]]></add>
        </operation>
    </file>

    <!-- Layouts Position -->
    <file path="admin/controller/design/layout.php">
        <operation>
            <search><![CDATA[$this->response->setOutput($this->load->view('design/layout_form', $data));]]></search>
            <add position="replace"><![CDATA[
                $this->load->language('design/layout');

                $this->response->setOutput($this->load->view('plaza/design/plaza_layout', $data));
            ]]></add>
        </operation>
    </file>
	
	<!-- Fixed URL SEO -->
	
	<file path="catalog/controller/startup/seo_url.php">
		<operation>
			<search index="0"><![CDATA[if ($url[0] == 'information_id') {]]></search>
			<add position="before"><![CDATA[
			if ($url[0] == 'post_id') {
				$this->request->get['post_id'] = $url[1];
			}	
			if ($url[0] == 'post_list_id') {
				$this->request->get['post_list_id'] = $url[1];
			}
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[if ($query->row['query'] && $url[0] != 'information_id' && $url[0] != 'manufacturer_id' && $url[0] != 'category_id' && $url[0] != 'product_id') {]]></search>
			<add position="replace"><![CDATA[
			if ($query->row['query'] && $url[0] != 'information_id' && $url[0] != 'post_list_id' && $url[0] != 'post_id' && $url[0] != 'manufacturer_id' && $url[0] != 'category_id' && $url[0] != 'product_id') {
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[$this->request->get['route'] = $query->row['query'];]]></search>
			<add position="after"><![CDATA[
			if($query->row['query'] && $url[0] == 'ptblog') {
				$this->request->get['route'] = "plaza/blog";
			}	
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[$this->request->get['route'] = 'information/information';]]></search>
			<add position="after"><![CDATA[
				} elseif (isset($this->request->get['post_id'])) {
					$this->request->get['route'] = 'plaza/blog/post';
				} elseif (isset($this->request->get['post_list_id'])) {
					$this->request->get['route'] = 'plaza/blog/category';
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[if (isset($data['route'])) {]]></search>
			<add position="after"><![CDATA[
			if($data['route'] == 'plaza/blog') {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'ptblog' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

						if ($query->num_rows && $query->row['keyword']) {
							$url .= '/' . $query->row['keyword'];

							unset($data[$key]);
						}
					}
				}
			}	
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {]]></search>
			<add position="before"><![CDATA[
			foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if($data['route'] == 'plaza/blog/post' && $key == 'post_id') {
					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

					if ($query->num_rows && $query->row['keyword']) {
						$url .= '/' . $query->row['keyword'];

						unset($data[$key]);
					}
				}

				if($data['route'] == 'plaza/blog/category' && $key == 'post_list_id') {
					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

					if ($query->num_rows && $query->row['keyword']) {
						$url .= '/' . $query->row['keyword'];

						unset($data[$key]);
					}
				}	
			]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[} elseif ($key == 'path') {]]></search>
			<add position="before"><![CDATA[
			} elseif ($key == 'route') {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
			if ($query->num_rows && $query->row['keyword']) {
				$url .= '/' . $query->row['keyword'];
				unset($data[$key]);
			} else if ($data['route'] == "common/home") { 
			 $url .= '/'; 
			} 	
			]]></add>
		</operation>
	</file>
</modification>