switch($type){ case self::TYPE_LOWEST_PRICE: $criteria->addSorting(newPriceSorting(SortingInterface::SORT_ASC)); break; case self::TYPE_HIGHEST_PRICE: $criteria->addSorting(newPriceSorting(SortingInterface::SORT_DESC)); break; case self::TYPE_TOPSELLER: $criteria->addSorting(newPopularitySorting(SortingInterface::SORT_DESC)); break; case self::TYPE_NEWCOMER: $criteria->addSorting(newReleaseDateSorting(SortingInterface::SORT_DESC)); break; case self::TYPE_RANDOM:
switch($sort){ case 'price_asc': $criteria->addSorting(newPriceSorting(SortingInterface::SORT_ASC)); break; case 'price_desc': $criteria->addSorting(newPriceSorting(SortingInterface::SORT_DESC)); break; case 'topseller': $criteria->addSorting(newPopularitySorting(SortingInterface::SORT_DESC)); break; case 'newcomer': $criteria->addSorting(newReleaseDateSorting(SortingInterface::SORT_DESC)); break; }