/** * Display a list of all categories * * @return void */ public function displayTask() { // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int')); $obj = new Archive(); // Get record count $this->view->total = $obj->products('count', $this->view->filters); // Get records $this->view->rows = $obj->products('list', $this->view->filters); // For all records here get SKUs $skus = new \stdClass(); $warehouse = new Warehouse(); foreach ($this->view->rows as $r) { $key = $r->pId; $allSkus = $warehouse->getProductSkus($r->pId, 'all', false); // Count how many active and how many inactive SKUs there are $skuCounter = new \stdClass(); $skuCounter->active = 0; $skuCounter->inactive = 0; foreach ($allSkus as $skuInfo) { if ($skuInfo->sActive) { $skuCounter->active++; } else { $skuCounter->inactive++; } } $skus->{$key} = $skuCounter; } $this->view->skus = $skus; // access groups $accessGroups = array(); if ($this->config->get('productAccess')) { $ag = \Hubzero\Access\Group::all()->rows(); $accessGroups[0] = 'None'; foreach ($ag as $obj) { $accessGroups[$obj->get('id')] = $obj->get('title'); } } else { $ag = Access::assetgroups(); $accessGroups[0] = 'All'; foreach ($ag as $obj) { $accessGroups[$obj->value] = $obj->text; } } $this->view->ag = $accessGroups; // Output the HTML $this->view->set('config', $this->config)->display(); }
/** * Get a count or list of skus * * @param string $rtrn What data to return * @param int $pId products * @param array $filters Filters to apply to data retrieval * @return mixed */ public function skus($rtrn = 'list', $pId, $filters = array()) { if (!isset($filters['sort'])) { $filters['sort'] = 'title'; } if (!isset($filters['sort_Dir'])) { $filters['sort_Dir'] = 'ASC'; } $warehouse = new Warehouse(); switch (strtolower($rtrn)) { case 'count': $this->_count = $warehouse->getProductSkus($pId, 'count', false); return $this->_count; break; case 'list': case 'rows': case 'results': default: if (!($results = $warehouse->getProductSkus($pId, 'rows', false))) { $results = array(); } else { // Get SKUs info $results = $warehouse->getSkusInfo($results, true, $filters); // Strip to just info $resultsPlain = array(); foreach ($results as $k => $res) { $resultsPlain[] = $res['info']; } $results = $resultsPlain; } $this->_products = new \Hubzero\Base\ItemList($results); return $this->_products; } }