Modify

Opened 3 years ago

Closed 3 years ago

#2399 closed Aufgabe (fixed)

Performance-Verbesserung auch für xtcCheckSpecial()

Reported by: noRiddle Owned by: somebody
Priority: normal Milestone: modified-shop-2.0.8.0
Component: Shop Version: 2.0.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

In der Preisklasse wird der return-Wert der diversen Funktionen xtcCheck...() schön mittels static Variablen ge-cache-t. Leider nicht bei xtcCheckSpecial().
Wenn man z.B. in der Box last_viewed, bei den also_purchased oder im Warenkorb Artikel hat die in einem oder gar mehreren der Genannten ebenfalls vorkommen wird die Funktion mehrfach ausgeführt.
Das ließe sich jedoch auch wunderbar cache-n, indem man aus $special_price ein Array macht mit jeweils dem Schlüssel der Produkt-ID ($pID).

Vielleicht so:

function xtcCheckSpecial($pID) {
    static $special_price;
    if(!isset($special_price)) {
      $special_price = array();
    }
    
    $this->flagSpecial = false;
    if ($this->cStatus['customers_status_specials'] == '1') {
      if(!isset($special_price[$pID])) {
        $special_price[$pID] = 0;
        $product_query = xtc_db_query("SELECT *
                                         FROM ".TABLE_SPECIALS."
                                        WHERE products_id = '".(int)$pID."'
                                              ".SPECIALS_CONDITIONS);
        if (xtc_db_num_rows($product_query) > 0) {
          $product = xtc_db_fetch_array($product_query);
          $this->flagSpecial = true;
          
          $product = $this->priceModules->CheckSpecial($product, $pID);
        
          $special_price[$pID] = $product['specials_new_products_price'];
        }
        
        $special_price[$pID] = $this->priceModules->CheckSpecialPrice($special_price[$pID], $pID);
      }
      
      return $special_price[$pID];
    }
  }

Da $this->flagSpecial nirgends benutzt wird habe ich das in meinem Schnellschuß-Beispiel mal unberührt gelassen.
Wenn das zukünftig verwendet werden sollte müsste es in der Funktion anders behandelt werden.

Gruß,
noRiddle

Attachments (0)

Change History (1)

comment:1 by Gerhard Waldemair, 3 years ago

Resolution: fixed
Status: newclosed

In 14791:

fix #2399 - use static array for method in xtcPrice

Modify Ticket

Action
as closed The owner will remain somebody.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.