Beispiel #1
0
 /**
  * Get a count or list of products
  *
  * @param      string  $rtrn    What data to return
  * @param      array   $filters Filters to apply to data retrieval
  * @param      boolean $boolean Clear cached data?
  * @return     mixed
  */
 public function products($rtrn = 'list', $filters = array(), $clear = false)
 {
     if (!isset($filters['sort'])) {
         $filters['sort'] = 'title';
     }
     if (!isset($filters['sort_Dir'])) {
         $filters['sort_Dir'] = 'ASC';
     }
     switch (strtolower($rtrn)) {
         case 'count':
             if (!isset($this->_products_count) || !is_numeric($this->_products_count) || $clear) {
                 $warehouse = new Warehouse();
                 // Reset limit, since all records count is needed here
                 unset($filters['limit']);
                 $this->_products_count = $warehouse->getProducts('count', false, $filters);
             }
             return $this->_products_count;
             break;
         case 'list':
         case 'rows':
         case 'results':
         default:
             if (!$this->_products instanceof \Hubzero\Base\ItemList || $clear) {
                 $warehouse = new Warehouse();
                 if (!($results = $warehouse->getProducts('rows', false, $filters))) {
                     $results = array();
                 }
                 $this->_products = new \Hubzero\Base\ItemList($results);
                 return $this->_products;
             }
             break;
     }
 }