Modify ↓
Opened 8 years ago
Closed 8 years ago
#1306 closed Frage (fixed)
orders_info_blocks.php : Optimieren zweier Schleifen
| Reported by: | anonymous | Owned by: | somebody |
|---|---|---|---|
| Priority: | normal | Milestone: | modified-shop-2.0.4.0 |
| Component: | Admin | Version: | 2.0.3.0 |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: |
Description
In der Datei ./admin/includes/modules/orders_info_blocks.php
gibt es zwei Stellen mit einer for-Schleife:
Zeile 181ff
if (isset($order->products[$i]!['attributes']) && sizeof($order->products[$i]!['attributes']) > 0) {
for ($j = 0, $k = sizeof($order->products[$i]!['attributes']); $j < $k; $j ++) {
echo '<br /><nobr><i> - '.$order->products[$i]!['attributes'][$j]!['option'].': '.$order->products[$i]!['attributes'][$j]!['value'].'</i></nobr> ';
}
}
und Zeile 191ff
if (isset($order->products[$i]!['attributes']) && sizeof($order->products[$i]!['attributes']) > 0) {
for ($j = 0, $k = sizeof($order->products[$i]!['attributes']); $j < $k; $j ++) {
$model = $order->products[$i]!['attributes'][$j]!['attributes_model'];
if ($model == !'') {
$model = xtc_get_attributes_model($order->products[$i]!['id'], $order->products[$i]!['attributes'][$j]!['value'],$order->products[$i]!['attributes'][$j]!['option'], $lang);
}
echo (!empty($model) ? $attr_model_delimiter . $model : '<br />');
}
}
wäre es nicht besser , diese Stellen wie folgt umzuschreiben:
Zeile 181ff
if ( isset($order->products[$i]!['attributes']) ) {
$k = sizeof($order->products[$i]!['attributes']);
if ( $k > 0 ) {
for ($j = 0; $j < $k; $j ++) {
echo '<br /><nobr><i> - '.$order->products[$i]!['attributes'][$j]!['option'].': '.$order->products[$i]!['attributes'][$j]!['value'].'</i></nobr> ';
}
}
}
und Zeile 191ff
if ( isset($order->products[$i]!['attributes']) ) {
/*$k = sizeof($order->products[$i]!['attributes']);*/
if ( $k > 0) {
for ($j = 0; $j < $k; $j++) {
$model = $order->products[$i]!['attributes'][$j]!['attributes_model'];
if ($model == !'') {
$model = xtc_get_attributes_model($order->products[$i]!['id'], $order->products[$i]!['attributes'][$j]!['value'],$order->products[$i]!['attributes'][$j]!['option'], $lang);
}
echo (!empty($model) ? $attr_model_delimiter . $model : '<br />');
}
}
}
Damit müsste die Größe des Arrays mit den Attributen nur einmal bestimmt werden, und nicht bei jeder Schleife bei jedem Durchgang.
Ich habe die zweite Zeile mit der Größenbestimmung erst einmal auskommentiert, eventuell kann man auf diese verzichten.
Grüße
Rene
Attachments (0)
Note:
See TracTickets
for help on using tickets.

Kann man durchaus optimieren