public function execute() { $product_id = $this->get('product_id', true); $this->checkProductRights($product_id); $data = waRequest::post(); $skus_model = new shopProductSkusModel(); if ($sku_id = $skus_model->add($data)) { $_GET['id'] = $sku_id; $method = new shopProductSkusGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } }
public function execute() { $sku_id = $this->get('id', true); $skus_model = new shopProductSkusModel(); $sku = $skus_model->getById($sku_id); if (!$sku) { throw new waAPIException('invalid_param', 'SKU not found', 404); } $this->checkProductRights($sku['product_id']); $data = waRequest::post(); if ($skus_model->update($sku_id, $data)) { $method = new shopProductSkusGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } }