/**
  * Remove an optional attribute from a product
  *
  * @param int $id          The product id
  * @param int $attributeId The attribute id
  *
  * @AclAncestor("pim_enrich_product_remove_attribute")
  *
  * @throws NotFoundHttpException     If product is not found or the user cannot see it
  * @throws AccessDeniedHttpException If the user does not have right to edit the product
  * @throws BadRequestHttpException   If the attribute is not removable
  *
  * @return JsonResponse
  */
 public function removeAttributeAction($id, $attributeId)
 {
     $product = $this->findProductOr404($id);
     if ($this->objectFilter->filterObject($product, 'pim.internal_api.product.edit')) {
         throw new AccessDeniedHttpException();
     }
     $attribute = $this->findAttributeOr404($attributeId);
     if (!$product->isAttributeRemovable($attribute)) {
         throw new BadRequestHttpException();
     }
     $this->productBuilder->removeAttributeFromProduct($product, $attribute);
     $this->productSaver->save($product);
     return new JsonResponse();
 }