public function execute() { if (!$this->getUser()->getRights('shop', 'settings')) { throw new waRightsException(_w('Access denied')); } $model = new shopFeatureModel(); if (($id = waRequest::get('id', waRequest::TYPE_INT)) && ($feature = $model->getById($id))) { $feature['values'] = $model->getFeatureValues($feature); $this->view->assign('feature', $feature); } else { throw new waException(_w('Product feature not found'), 404); } }
public function execute() { $feature_model = new shopFeatureModel(); if ($id = $this->get('id')) { $feature = $feature_model->getById($id); } elseif ($code = $this->get('code')) { $feature = $feature_model->getByCode($code); } else { throw new waAPIException('invalid_param', 'Required parameter is missing: id or code', 400); } if (!$feature) { throw new waAPIException('invalid_param', 'Feature not found', 404); } if ($feature['selectable']) { $feature['values'] = array_values($feature_model->getFeatureValues($feature)); $feature['values']['_element'] = 'value'; } $this->response = $feature; }