﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking
1306	orders_info_blocks.php : Optimieren zweier Schleifen	anonymous	somebody	"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>&nbsp; - '.$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>&nbsp; - '.$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"	Frage	closed	normal	modified-shop-2.0.4.0	Admin	2.0.3.0	fixed				
