/** * returns the inital (all) products, based on the all the eligile products * for the page. * * This is THE pivotal method that probably changes for classes that * extend ProductGroup as here you can determine what products or other buyables are shown. * * The return from this method will then be sorted and filtered to product the final product list * * @return DataObjectSet | Null **/ public function currentInitialProducts($extraFilter = null, $alternativeFilterKey = '') { $this->allProducts = parent::currentInitialProducts(); if (!$extraFilter) { $dos = null; //do nothing - show all products } elseif ($extraFilter instanceof DataList) { $dos = $tagOrTags; //do nothing } elseif ($tagOrTags instanceof DataObject) { $dos = new ArrayList(array($tagOrTags)); } elseif (is_array($extraFilter) || intval($extraFilter) == $extraFilter) { $dos = EcommerceProductTag::get()->filter(array("ID" => $extraFilter)); } else { return null; } //add at least one product - albeit a fake one... $idArray = array(); if ($dos && $dos->count()) { foreach ($dos as $do) { $products = $do->getManyManyComponents('Products'); if ($products && $products->count()) { $addedArray = $products->column("ID"); if (is_array($addedArray) && count($addedArray)) { $idArray = array_merge($idArray, $addedArray); } } } } if (count($idArray)) { $this->allProducts = $this->allProducts->filter(array("ID" => $idArray)); } return $this->allProducts; }