[Typo3-shop] tt-products, product sorting by pid (based on tree position)

Franz Holzinger franz at fholzinger.com
Fri Sep 16 13:10:50 CEST 2005


Hello Rick,
> I have an array with all the products so i use:
> uasort($myarray,myCompFunc())
> 
> So in my comp func i can easily get the pid of the rows:
> $pid1 = $row1['pid'];
> $pid2 = $row2['pid'];
> 
> Now comes the tricky part:
> I want to compare the both pids by there position in the tree. I couldnt 
> find a usefull function in the API, but i can't believe there isn't one.
> 
> So before i start writing my own function, can some one point me to a 
> function i can use?
> 
there is such a function in the Treelib from René Fritz. I have copied
this also in an extended form into the library of the Commerce
extension, but not yet published. So you need to contact the Commerce
leaders to get the code.



Franz



	/**
	 * Count subrecords with parent_id=$uid
	 * Additional WHERE clauses can be added by $where (fx. ' AND blabla=1')
	 *
	 * @param	integer		UIDs of records
	 * @param	string		Additional WHERE clause, eg. " AND blablabla=0"
	 * @return	integer		Count of subrecords
	 */
	function countSubRecords($uid,$where='')	
...




	/**
	 * Returns an array with rows for subrecords with parent_id=$uid
	 *
	 * @param	integer		UID of parent of records
	 * @param	string		List of fields to select (default is '*')
	 * @param	string		Additional WHERE clause, eg. " AND blablabla=0"
	 * @param 	boolean 	Enable sorting
	 * @return	array		Returns the rows if found, otherwise empty array
	 */
	function getSubRecords ($uid, $fields='', $where='', $sorting=true)	{


...



More information about the TYPO3-project-tt-products mailing list