[TYPO3-commerce] RFC Bug: #39420 - Improve performance in class.tx_commerce_db_category.php

Georg Schönweger georg.schoenweger at gmail.com
Tue Jul 31 16:52:36 CEST 2012


This is an SVN Patch request

Type: Bugfix

Bugtracker reference: http://forge.typo3.org/issues/39420

Branches: trunk

Problem:
The query for getting products in class.tx_commerce_db_category.php
could be simplified.
Don't know why it will query articles and prices too, IMO this does not
make sense and leads to a big while loop if you have more than 1 article
/ price per product ... (immagine a shop with many different articles
and different prices)

Solution:
Attached patch queries only products.

Additional Notes:


regards,
Georg
-------------- next part --------------
--- class.tx_commerce_db_category.orig.php	2012-07-31 16:23:33.356400411 +0200
+++ class.tx_commerce_db_category.php	2012-07-31 16:41:09.912378776 +0200
@@ -269,19 +269,15 @@
 			$localOrderField = $hookObj->productOrder($localOrderField,$this);
 		}
 		$where_clause = 'AND tx_commerce_products_categories_mm.uid_foreign = ' . intval($uid);
-		$where_clause.= ' AND tx_commerce_products.uid=tx_commerce_articles.uid_product ';
-		$where_clause.= ' AND tx_commerce_articles.uid=tx_commerce_article_prices.uid_article ';
 		if (is_object($GLOBALS['TSFE']->sys_page)) {
 			$where_clause .= $GLOBALS['TSFE']->sys_page->enableFields('tx_commerce_products', $GLOBALS['TSFE']->showHiddenRecords);
-			$where_clause .= $GLOBALS['TSFE']->sys_page->enableFields('tx_commerce_articles', $GLOBALS['TSFE']->showHiddenRecords);
-			$where_clause .= $GLOBALS['TSFE']->sys_page->enableFields('tx_commerce_article_prices', $GLOBALS['TSFE']->showHiddenRecords);
 		}
 
 			// Versioning - no deleted or versioned records, nor live placeholders
 		$where_clause .= ' AND tx_commerce_products.deleted = 0 AND tx_commerce_products.pid != -1 AND tx_commerce_products.t3ver_state != 1';
 		$queryArray = array(
 			'SELECT' => 'tx_commerce_products.uid',
-			'FROM' => 'tx_commerce_products ,tx_commerce_products_categories_mm,tx_commerce_articles, tx_commerce_article_prices',
+			'FROM' => 'tx_commerce_products ,tx_commerce_products_categories_mm',
 			'WHERE' => 'tx_commerce_products.uid=tx_commerce_products_categories_mm.uid_local ' . $where_clause,
 			'GROUPBY' => '',
 			'ORDERBY' => $localOrderField,


More information about the TYPO3-team-commerce mailing list