/** * Remove an attribute form a product * * @param integer $productId * @param integer $attributeId * * @AclAncestor("pim_enrich_product_remove_attribute") * @return RedirectResponse * * @throws NotFoundHttpException */ public function removeAttributeAction($productId, $attributeId) { $product = $this->findProductOr404($productId); $attribute = $this->findOr404($this->productManager->getAttributeName(), $attributeId); if ($product->isAttributeRemovable($attribute)) { $this->productManager->removeAttributeFromProduct($product, $attribute); } else { throw new DeleteException($this->getTranslator()->trans('product.attribute not removable')); } if ($this->getRequest()->isXmlHttpRequest()) { return new Response('', 204); } else { return $this->redirectToRoute('pim_enrich_product_edit', array('id' => $productId)); } }