Hey Guys,
I have a slight twist on a similar sorting issue. The case is in SS2.4.1, with a custom modified shop 0.8.3.
I have a standard product category page where all products for that category are displayed. However, when a product price is listed as 0 the product is still listed and displays as "POA" (for Pricing on Application).
For sorting by price any product of POA is currently listed first (makes sense as the price is 0), however I need any POA product to display at the end of the results after products with actual pricing, instead of the start. Is there anyway I can specify in the sorting code for products with a pricing of 0 to be listed last in the set...
I believe the magic for this currently happens in Productgroup.php within the Productshowable function (shown below)
function ProductsShowable($extraFilter = '', $recursive = true){
$filter = ""; //
$join = "";
$this->extend('updateFilter',$extraFilter);
if($extraFilter) $filter.= " AND $extraFilter";
//added =0 to show 0/poa products 01062012
if(self::$must_have_price) $filter .= " AND \"Price\" >= 0";
$limit = (isset($_GET['start']) && (int)$_GET['start'] > 0) ? (int)$_GET['start'].",".self::$page_length : "0,".self::$page_length;
$sort = (isset($_GET['sortby'])) ? Convert::raw2sql($_GET['sortby']) : "\"FeaturedProduct\" DESC,\"URLSegment\"";
//hard coded sort configuration //TODO: make these custom
if($sort == "NumberSold") $sort .= " DESC";
$groupids = array($this->ID);
if(($recursive === true || $recursive === 'true') && self::$include_child_groups && $childgroups = $this->ChildGroups(true))
$groupids = array_merge($groupids,$childgroups->map('ID','ID'));
$groupidsimpl = implode(',',$groupids);
$join = $this->getManyManyJoin('Products','Product');
$multicatfilter = $this->getManyManyFilter('Products','Product');
//TODO: get products that appear in child groups (make this optional)
$products = DataObject::get('Product',"(\"ParentID\" IN ($groupidsimpl) OR $multicatfilter) $filter",$sort,$join,$limit);
$allproducts = DataObject::get('Product',"\"ParentID\" IN ($groupidsimpl) $filter","",$join);
if($allproducts) $products->TotalCount = $allproducts->Count(); //add total count to returned data for 'showing x to y of z products'
if($products && $products instanceof DataObjectSet) $products->removeDuplicates();
return $products;
}
I'd definitely appreciate any help on this.
Thank you,