/** * Display association grids * * @param Request $request the request * @param integer $id the product id (owner) * * @AclAncestor("pim_enrich_associations_view") * * @return Response */ public function associationsAction(Request $request, $id) { $product = $this->findProductOr404($id); $this->productManager->ensureAllAssociationTypes($product); $associationTypes = $this->doctrine->getRepository('PimCatalogBundle:AssociationType')->findAll(); return $this->templating->renderResponse('PimEnrichBundle:Association:_associations.html.twig', array('product' => $product, 'associationTypes' => $associationTypes, 'dataLocale' => $request->get('dataLocale', null))); }
/** * Update product * * @param Request $request * @param integer $id * * @Template("PimEnrichBundle:Product:edit.html.twig") * @AclAncestor("pim_enrich_product_index") * @return RedirectResponse */ public function updateAction(Request $request, $id) { $product = $this->findProductOr404($id); $this->productManager->ensureAllAssociationTypes($product); $form = $this->createForm('pim_product_edit', $product, $this->getEditFormOptions($product)); $form->submit($request, false); if ($form->isValid()) { try { $this->mediaManager->handleProductMedias($product); $this->productSaver->save($product); $this->addFlash('success', 'flash.product.updated'); } catch (MediaManagementException $e) { $this->addFlash('error', $e->getMessage()); } $params = ['id' => $product->getId(), 'dataLocale' => $this->getDataLocaleCode()]; if ($comparisonLocale = $this->getComparisonLocale()) { $params['compareWith'] = $comparisonLocale; } return $this->redirectAfterEdit($params); } else { $this->addFlash('error', 'flash.product.invalid'); } $channels = $this->getRepository('PimCatalogBundle:Channel')->findAll(); $trees = $this->productCatManager->getProductCountByTree($product); return $this->getProductEditTemplateParams($form, $product, $channels, $trees); }