Show the form for editing the specified resource.

@param  Product $product
@return Response
189305
public function edit(Product $product)
    {
        $categories = $this->category->all()->nest()->listsFlattened('name');

        $shops = $this->shop->all();

        $optionTypes = $this->optionManager->all();

        return view('product::admin.products.edit', compact('product', 'categories', 'shops', 'optionTypes'));
    }
732786
public function showAction(Product $product)
    {

        if (!$product) {
            throw $this->createNotFoundException('Unable to find Product entity.');
        }

        $deleteForm = $this->createDeleteForm($product->getId());

        return array(
            'entity' => $product,
            'delete_form' => $deleteForm->createView(),
        );
    }
1296583
public function updateAction(Request $request, Product $entity)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $this->addProductItemFieldData($entity);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Product entity.');
        }

        $deleteForm = $this->createDeleteForm($entity->getId());
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            /* @var ProductRawMaterial $productRawMaterial */
            foreach ($entity->getRawMaterials() as $productRawMaterial) {
                $productRawMaterial->setProduct($entity);
            }
            $em->flush();

            return $this->redirect($this->generateUrl('admin_product_show', array('id' => $entity->getId())));
        }

        return array(
            'entity' => $entity,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
864947
protected function prepareProduct(array &$product)
    {
        $selected = $this->getSelectedCombinationProduct($product);
        $this->unshiftSelectedImageProduct($selected, $product);

        $this->setItemImages($product, 'product', $this->image);
        $this->setItemThumbProduct($product, $this->image);
        $this->setItemProductInComparison($product, $this->product_compare);
        $this->setItemProductBundle($product, $this->product, $this->image);
        $this->setItemProductInWishlist($product, $this->wishlist);

        $this->setItemPriceCalculated($selected, $this->product);
        $this->setItemPriceFormatted($selected, $this->price, $this->current_currency);

        $product['selected_combination'] = $selected;
        $product['total_reviews'] = $this->getTotalReviewsProduct($product);

        $this->setItemProductFields($product, $this->image, $this->product_class);
    }
890706
public function updateAction(ProductItemFieldData $productitemfielddata, Request $request)
    {
        $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array(
            'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())),
            'method' => 'PUT',
        ));
        if ($editForm->handleRequest($request)->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId())));
        }
        $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete');

        return array(
            'productitemfielddata' => $productitemfielddata,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
22730
public function update($product)
    {
        $productId = "";

        if (is_array($product)) {
            $productId = $product["id"];
            unset($product["id"]);
        }
        elseif (is_object($product)) {
            $productId = $product->id;
            unset($product->id);
        }

        return $this->client->put("/products/" . rawurlencode($productId), $product);
    }
850790
private function createEditForm(ProductOrderItem $entity)
    {
        $form = $this->createForm(new ProductOrderItemType(), $entity, array(
            'action' => $this->generateUrl('admin_orderitem_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
269517
public function getAction(Request $request, $productId)
    {
        $locale = $request->get('locale');
        $product = $this->fetchProduct($productId);

        $content = $this->getProductContentMapper()->get($product, $locale);

        $view = $this->view($content, Response::HTTP_OK);

        return $this->handleView($view);
    }
610737
public function newAction(Product $product, Request $request)
    {
        $restock = new RestockTransaction();
        $restock->setProduct($product);

        $form = $this->createForm(new RestockTransactionType(), $restock);

        if ($request->getMethod() == 'POST')
        {
            $form->bindRequest($request);

            if ($form->isValid())
            {
                try
                {
                    // For now, we always post the RestockTransaction, but
                    // later we'll check to see if this is a future transaction
                    $restock->post();

                    $em = $this->getDoctrine()->getEntityManager();
                    $em->persist($restock);
                    $em->flush();

                    return $this->redirect($this->generateUrl('Seller_product_show', array(
                        'id' => $product->getId(),
                    )));
                }
                catch (\Exception $e)
                {
                    // could not Restock Product
                }
            }
        }

        return $this->render('HarvestCloudCoreBundle:Seller/RestockTransaction:new.html.twig', array(
          'form'    => $form->createView(),
          'product' => $product,
        ));
    }
981178
public function show(Product $product)
    {
        $product->load('group', 'category');

        //increasing product counters, in order to have a suggestion orden
        (new ProductsRepository)->increment('view_counts', $product);

        //saving the product tags into users preferences
        if (trim($product->tags) != '' && auth()->check()) {
            auth()->user()->updatePreferences('product_viewed', $product->tags);
        }

        return view('products.detailProd', [
            'suggestions' => Suggestions\Suggest::for('product_viewed')->shake()->get('product_viewed'),
            'reviews' => OrderDetail::ReviewsFor($product->id),
            'allWishes' => Order::forSignedUser('wishlist'),
            'features' => Feature::filterable()->get(),
            'product' => $product,
        ]);
    }
250699
public function setProduct(\Magento\Catalog\Model\Product $product)
    {
        $this->setProductName($product->getName());
        $this->setProductSku($product->getSku());

        return $this;
    }
1149369
public function updateGalleryItemAction(Request $request, GalleryItem $entity, Product $product)
    {
        $em = $this->getDoctrine()->getManager();

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find GalleryItem entity.');
        }

        $deleteForm = $this->createDeleteGalleryItemForm($entity->getId());
        $editForm = $this->createEditGalleryItemForm($entity, $product);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            return $this->redirect($this->generateUrl('admin_product_show', array('id' => $product->getId())));
        }

        return array(
            'entity' => $entity,
            'product' => $product,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
612565
public function variationToProductAction(ProductInterface $product, ProductInterface $variation = null)
    {
        $request = $this->getCurrentRequest();
        $provider = $this->get('sonata.product.pool')->getProvider($product);

        if (!$provider->hasEnabledVariations($product)) {
            throw new NotFoundHttpException('invalid product instance (no variations)');
        }

        if (null === $variation || 0 === $provider->getStockAvailable($variation)) {
            if ($request->isXmlHttpRequest()) {
                return new JsonResponse(['error' => $this->get('translator')->trans('variation_not_found', [], 'SonataProductBundle')]);
            }

            $this->get('session')->getFlashBag()->add('sonata_product_error', 'variation_not_found');

            // Go to master product
            $variation = $product;
        }

        $url = $this->generateUrl('sonata_product_view', [
            'productId' => $variation->getId(),
            'slug' => $variation->getSlug(),
        ]);

        if ($request->isXmlHttpRequest()) {
            return new JsonResponse(['variation_url' => $url]);
        }

        return $this->redirect($url);
    }
40080
public function edit(Role $role, $child = null)
    {
        $role->permissions = $role->permissions()->pluck('name')->all();

        return view('roles::admin.edit')
            ->with(['model' => $role]);
    }
434101
public function productFormAction()
    {
        $userLocale = $this->getUser()->getLocale();

        $status = $this->getStatus($userLocale);
        $units = $this->getUnits($userLocale);
        $deliveryStates = $this->getDeliveryStates($userLocale);

        return $this->render(
            'SuluProductBundle:Template:product.form.html.twig',
            [
                'MAX_SEARCH_TERMS_LENGTH' => ProductManager::MAX_SEARCH_TERMS_LENGTH,
                'status' => $status,
                'units' => $units,
                'deliveryStates' => $deliveryStates,
                'categoryUrl' => $this->getCategoryUrl(),
            ]
        );
    }
551389
public function updateAction(ProductItemField $productitemfield, Request $request)
    {
        $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field"), $productitemfield, array(
            'action' => $this->generateUrl('admin_productitemfield_update', array('id' => $productitemfield->getid())),
            'method' => 'PUT',
        ));
        if ($editForm->handleRequest($request)->isValid()) {
            $productitemSrv = $this->get('amulen.shop.product.item.field');
            $productitemSrv->uploadImage($productitemfield);
            $this->getDoctrine()->getManager()->flush();

            return $this->redirect($this->generateUrl('admin_productitemfield_show', array('id' => $productitemfield->getId())));
        }
        return $this->redirect($this->generateUrl('admin_productitemfield_show', array('id' => $productitemfield->getId())));
    }
1172246
protected function submitEditProduct()
    {
        if ($this->isPosted('delete')) {
            $this->deleteProduct();
        } else if ($this->isPosted('save') && $this->validateEditProduct()) {
            $this->deleteImagesProduct();
            if (isset($this->data_product['product_id'])) {
                $this->updateProduct();
            } else {
                $this->addProduct();
            }
        }
    }