public function execute()
 {
     $id = $this->post('id', true);
     $images_model = new shopProductImagesModel();
     $image = $images_model->getById($id);
     if (!$image) {
         throw new waAPIException('invalid_param', 'Product image not found', 404);
     }
     // check product rights
     $this->getProduct($image['product_id']);
     $product_images_model = new shopProductImagesModel();
     if ($product_images_model->delete($id)) {
         $this->response = true;
     } else {
         throw new waAPIException('server_error', 500);
     }
 }
 public function execute()
 {
     $id = waRequest::get('id', null, waRequest::TYPE_INT);
     if (!$id) {
         throw new waException(_w("Unknown image"));
     }
     $product_images_model = new shopProductImagesModel();
     $image = $product_images_model->getById($id);
     if (!$image) {
         throw new waException(_w("Unknown image"));
     }
     $product_model = new shopProductModel();
     if (!$product_model->checkRights($image['product_id'])) {
         throw new waException(_w("Access denied"));
     }
     if (!$product_images_model->delete($id)) {
         throw new waException(_w("Coudn't delete image"));
     }
     $this->response['id'] = $id;
 }