Hey, great extension, thank you very much!
Arne Bakkebø is right with extended_sort I think, but I like this one =)
Maybe you are interested to add my little extension to yours to sort by price:
case 'sort_key':
$objectA = self::getObjectAttributeSortKey( $objectA, $attributeName );
$objectB = self::getObjectAttributeSortKey( $objectB, $attributeName );
$objectAAttributeValue = '';
$objectBAttributeValue = '';
// if price is gt... (sort_key_int)
if ( $objectA > $objectB ) {
// Making ObjectA to be less than ObjectB
// Jumping to comparing function
$objectAAttributeValue = 'a';
$objectBAttributeValue = 'b';
} else {
$objectAAttributeValue = 'b';
$objectBAttributeValue = 'a';
}
break;
public static function getObjectAttributeSortKey( $object, $attributeName ) {
$attribute = self::getObjectAttribute( $object, $attributeName );
//sort_key_int sometimes has a difference from 1, maybe a bug...
//return $attribute->SortKeyInt;
$Price = sprintf ( '%01.2f', $attribute->DataFloat );
$PriceInt = (int) str_replace(',','',str_replace('.','',str_replace(' ','',$Price)));
return $PriceInt;
}
{def $sorted_children = get_sorted_objects( $children_arr, array(
array(
false(),
array( 'sort_key', 'price' )
)
))}
best regards
scrieler