Code Duplication    Length = 19-22 lines in 4 locations

catalog/index.php 1 location

@@ 106-127 (lines=22) @@
103
104
    $search_query = 'select SQL_CALC_FOUND_ROWS';
105
106
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
107
      switch ($column_list[$i]) {
108
        case 'PRODUCT_LIST_MODEL':
109
          $search_query .= ' p.products_model,';
110
          break;
111
        case 'PRODUCT_LIST_NAME':
112
          $search_query .= ' pd.products_name,';
113
          break;
114
        case 'PRODUCT_LIST_MANUFACTURER':
115
          $search_query .= ' m.manufacturers_name,';
116
          break;
117
        case 'PRODUCT_LIST_QUANTITY':
118
          $search_query .= ' p.products_quantity,';
119
          break;
120
        case 'PRODUCT_LIST_IMAGE':
121
          $search_query .= ' p.products_image,';
122
          break;
123
        case 'PRODUCT_LIST_WEIGHT':
124
          $search_query .= ' p.products_weight,';
125
          break;
126
      }
127
    }
128
129
// show the products of a specified manufacturer
130
    if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {

catalog/advanced_search_result.php 1 location

@@ 166-184 (lines=19) @@
163
164
  $search_query = 'select SQL_CALC_FOUND_ROWS distinct';
165
166
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
167
    switch ($column_list[$i]) {
168
      case 'PRODUCT_LIST_MODEL':
169
        $search_query .= ' p.products_model,';
170
        break;
171
      case 'PRODUCT_LIST_MANUFACTURER':
172
        $search_query .= ' m.manufacturers_name,';
173
        break;
174
      case 'PRODUCT_LIST_QUANTITY':
175
        $search_query .= ' p.products_quantity,';
176
        break;
177
      case 'PRODUCT_LIST_IMAGE':
178
        $search_query .= ' p.products_image,';
179
        break;
180
      case 'PRODUCT_LIST_WEIGHT':
181
        $search_query .= ' p.products_weight,';
182
        break;
183
    }
184
  }
185
186
  $search_query .= ' m.manufacturers_id, p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, pd.products_name, 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';
187

catalog/products_new.php 1 location

@@ 47-68 (lines=22) @@
44
45
  $listing_sql = 'select SQL_CALC_FOUND_ROWS';
46
47
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
48
    switch ($column_list[$i]) {
49
      case 'PRODUCT_LIST_MODEL':
50
        $listing_sql .= ' p.products_model,';
51
        break;
52
      case 'PRODUCT_LIST_NAME':
53
        $listing_sql .= ' pd.products_name,';
54
        break;
55
      case 'PRODUCT_LIST_MANUFACTURER':
56
        $listing_sql .= ' m.manufacturers_name,';
57
        break;
58
      case 'PRODUCT_LIST_QUANTITY':
59
        $listing_sql .= ' p.products_quantity,';
60
        break;
61
      case 'PRODUCT_LIST_IMAGE':
62
        $listing_sql .= ' p.products_image,';
63
        break;
64
      case 'PRODUCT_LIST_WEIGHT':
65
        $listing_sql .= ' p.products_weight,';
66
        break;
67
    }
68
  }
69
70
  $listing_sql .= ' 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 where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id';
71

catalog/specials.php 1 location

@@ 45-66 (lines=22) @@
42
43
  $select_column_list = '';
44
45
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
46
    switch ($column_list[$i]) {
47
      case 'PRODUCT_LIST_MODEL':
48
        $select_column_list .= 'p.products_model, ';
49
        break;
50
      case 'PRODUCT_LIST_NAME':
51
        $select_column_list .= 'pd.products_name, ';
52
        break;
53
      case 'PRODUCT_LIST_MANUFACTURER':
54
        $select_column_list .= 'm.manufacturers_name, ';
55
        break;
56
      case 'PRODUCT_LIST_QUANTITY':
57
        $select_column_list .= 'p.products_quantity, ';
58
        break;
59
      case 'PRODUCT_LIST_IMAGE':
60
        $select_column_list .= 'p.products_image, ';
61
        break;
62
      case 'PRODUCT_LIST_WEIGHT':
63
        $select_column_list .= 'p.products_weight, ';
64
        break;
65
    }
66
  }
67
68
  $listing_sql = "select SQL_CALC_FOUND_ROWS " . $select_column_list . " 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 where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = :language_id and s.status = '1'";
69