public function execute() { $id = $this->get('id', true); $product = $this->getProduct($id); $data = waRequest::post(); if (isset($data['type_id'])) { $this->checkRights($data['type_id']); } $this->checkSku($data); $p = new shopProduct($product); if ($p->save($data, true, $errors)) { $_GET['id'] = $p->getId(); $method = new shopProductGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', implode(",\n", $errors), 500); } }
public function execute() { $data = waRequest::post(); $exclude = array('id', 'sku_type'); foreach ($exclude as $k) { if (isset($data[$k])) { unset($data[$k]); } } $this->post("name", true); $this->post("skus", true); $this->checkSku($data); // check access rights $this->checkRights($this->post("type_id", true)); $p = new shopProduct(); if ($p->save($data, true, $errors)) { $_GET['id'] = $p->getId(); $method = new shopProductGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', implode(",\n", $errors), 500); } }