Code Duplication    Length = 7-10 lines in 2 locations

catalog/index.php 2 locations

@@ 131-137 (lines=7) @@
128
129
// show the products of a specified manufacturer
130
    if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
131
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
132
// We are asked to show only a specific category
133
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m, :table_products_to_categories p2c where p.products_status = "1" and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
134
      } else {
135
// We show them all
136
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m where p.products_status = "1" and pd.products_id = p.products_id and pd.language_id = :language_id and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id';
137
      }
138
    } else {
139
// show the products in a given categorie
140
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
@@ 138-147 (lines=10) @@
135
// We show them all
136
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m where p.products_status = "1" and pd.products_id = p.products_id and pd.language_id = :language_id and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id';
137
      }
138
    } else {
139
// show the products in a given categorie
140
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
141
// We are asked to show only specific catgeory
142
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m, :table_products_to_categories p2c where p.products_status = "1" and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
143
      } else {
144
// We show them all
145
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products_description pd, :table_products p left join :table_manufacturers m on p.manufacturers_id = m.manufacturers_id left join :table_specials s on p.products_id = s.products_id, :table_products_to_categories p2c where p.products_status = "1" and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
146
      }
147
    }
148
149
    if ( (!isset($_GET['sort'])) || (!preg_match('/^[1-8][ad]$/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
150
      for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {