Finds and displays a Product entity.

@Route("/{slug}", name="product_show")
@Method("GET")
@Template()
775021
public function showAction($slug, Request $request)
    {
        $em = $this->getDoctrine()->getManager();

        $productService = $this->get("amulen.shop.product");
        $productOrderService = $this->get("amulen.shop.order");
        $productOrderItemService = $this->get("amulen.shop.order.item");

        $entity = $em->getRepository('AmulenShopBundle:Product')->findOneBy(array("slug" => $slug));

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Product entity.');
        } else {
            $seoPage = $this->container->get('sonata.seo.page');
            $baseTitle = $seoPage->getTitle();
            $title = ucfirst($entity->getName()) . " - Productos - " . $baseTitle;

            $seoPage->setTitle($title);
            $seoPage->addMeta('property', "og:type", "product");
            $seoPage->addMeta('property', "og:title", $title);
            $seoPage->addMeta('property', "og:description", $entity->getDescription());
            $seoPage->addMeta('property', "og:url", $this->generateUrl('product_show', [
                'slug' => $entity->getSlug()
            ], UrlGeneratorInterface::ABSOLUTE_URL));
            $seoPage->addMeta('property', "product:price:amount", $entity->getPrice());
            $seoPage->addMeta('property', "product:price:currency", 'ARS');


            if ($entity->getImage()) {
                $absoluteImageUrl = $this->generateUrl('base_path', [], UrlGeneratorInterface::ABSOLUTE_URL);
                $absoluteImageUrl .= $entity->getImage()->getPath();
                $seoPage->addMeta('property', "og:image", $absoluteImageUrl);
            }

        }

        $prodQty = 1;
        
        /* ProductOrder */
        $session = $request->getSession();
        $productOrderId = $session->get('productOrderId');
        $productOrder = $productOrderService->getProductOrder($productOrderId);
        if (!$productOrderId) {
            $session->set('productOrderId', $productOrder->getId());
        }


        return array(
            'entity' => $entity,
            'productQtyOrder' => $prodQty,
            'current_products' => $productOrder->getProductsAdded(),
        );
    }
229657
public function showAction(Product $product)
    {
        $deleteForm = $this->createDeleteForm($product);

        //disable notification
        $em = $this->getDoctrine()->getManager();
        $admin = $em->getRepository('CoreBundle:Actor')->find(1);//admin
        $notificationManager = $this->container->get('notification_manager');
        $notificationManager->disableNotificationByDetail(
                $admin, //current user
                $admin,//admin
                'new_product', 
                '"product":'.$product->getId().'}'
                );
        
        return array(
            'entity' => $product,
            'delete_form' => $deleteForm->createView(),
        );
    }
294021
public function actionCreate($type = 'product')
    {
        if (!is_product_type_name($type)) {
            throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
        }
        $model = new TermOfProductType();
        $model->product_type = $type;
        if ($model->loadAll(request()->post())) {
            if (!TermOfProductType::find()
                ->where(['product_type' => $model->product_type])
                ->andWhere(['name' => $model->name])
                ->exists()) {
                if ($model->saveAll()) {
                    return $this->redirect([
                        'update',
                        'id' => $model->id,
                    ]);
                }
            } else {
                $model->addError('name', t('app', 'This name has already been set.'));
            }
        }

        return $this->render('create', [
            'model' => $model,
        ]);
    }
933584
public function show($slug)
    {
        $page = Page::published()
            ->where('slug', $slug)
            ->first();

        if ($page === null) {
            app()->abort(404, 'page with slug \''.$slug.'\' not found');
        }

        $this->authorize('show', $page);

        return view('site::page')->with('page', $page);
    }
693568
public function showBySlugAction($slug)
    {
        $manager = $this->get('compo_faq.manager.faq');

        $article = $manager->findBySlug($slug);

        if (!$article) {
            throw $this->createNotFoundException('compo_faq.exception.not_found_article');
        }

        $manager->increaseViews($article);

        $seoPage = $this->get('sonata.seo.page');
        $seoPage->setContext('faq_show');
        $seoPage->addVar('faq', $article);

        $seoPage->addTemplates(
            'faq_show',
            [
                'header' => $article->getName(),
                'title' => $article->getName(),
                'metaKeyword' => $article->getMetaKeyword(),
                'metaDescription' => $article->getMetaDescription(),
            ]
        );

        $seoPage->setLinkCanonical($manager->getArticleShowPermalink($article, 0));

        $seoPage->build();

        return $this->render(
            'CompoFaqBundle:Faq:show.html.twig',
            [
                'article' => $article,
            ]
        );
    }
1100919
public function showAction(Profile $seller, $product_slug)
    {
        $q  = $this->get('doctrine')
            ->getManager()
            ->createQuery('
                SELECT p
                FROM HarvestCloudCoreBundle:Product p
                WHERE p.seller = :seller
                AND p.slug = :product_slug
            ')
            ->setParameter('product_slug', $product_slug)
            ->setParameter('seller', $seller)
        ;

        $product = $q->getSingleResult();

        $form = $this->createForm(new AddToCartType(
            $product,
            $this->getCurrentCart()->getQuantity($product)
        ));

        return $this->render('HarvestCloudCoreBundle:Buyer/Product:show.html.twig', array(
          'product'          => $product,
          'quantity_in_cart' => $this->getCurrentCart()->getQuantity($product),
          'lineItem'         => $this->getCurrentCart()->getLineItemForProduct($product),
          'form'             => $form->createView(),
        ));
    }
568524
public function index()
    {
        $productTypes = $this->productManager->all();
        $products = $this->product->all();

        return view('product::admin.products.index', compact('products', 'productTypes'));
    }
459633
public function persistProduct($product, $name = null)
    {

        // persist the new entity and return the ID
        $id = $this->getProductAction()->persist($product, $name);

        // add the product to the cache, register the SKU reference as well
        $this->getProductRepository()->toCache($product[MemberNames::SKU], $product, array($product[MemberNames::SKU] => $id));

        // return the ID of the persisted product
        return $id;
    }
1277122
public function show()
    {
        $params = static::$router->current()->parameters();
        $id     = Arr::get($params, 'id');
        $slug   = Arr::get($params, 'slug');

        $page = $this->getRequestedContent($id, $slug);
        $id   = $page->getAttribute('id');
        $slug = $page->getAttribute('slug');

        set_meta('title', $page->getAttribute('title'));

        return $this->getResponse($page, $id, $slug);
    }
910557
function product(subscribe) {
  const processProduct$ = productReceived$.merge(cachedProductReceived$);

  subscribe(productWillEnter$, ({ action, dispatch }) => {
    const { productId } = action.route.params;
    const { productId: variantId } = action.route.state;
    const id = variantId || hex2bin(productId);

    dispatch(fetchProduct(id));
    dispatch(fetchProductDescription(id));
    dispatch(fetchProductProperties(id));
    dispatch(fetchProductImages(id, productImageFormats.getAllUniqueFormats()));
    dispatch(fetchProductShipping(id));
  });

  subscribe(processProduct$, ({ action, dispatch }) => {
    const {
      id,
      flags = {
        hasVariants: false,
        hasOptions: false,
      },
      baseProductId,
    } = action.productData;

    if (baseProductId) {
      dispatch(fetchProduct(baseProductId));
      dispatch(fetchProductImages(baseProductId, productImageFormats.getAllUniqueFormats()));
    }

    if (flags.hasVariants) {
      dispatch(fetchProductVariants(id));
    }

    if (flags.hasOptions) {
      dispatch(fetchProductOptions(id));
    }
  });

  const receivedVisibleProductDebounced$ = receivedVisibleProduct$.debounceTime(500);
  /** Refresh product data after getting cache version for PDP */
  subscribe(receivedVisibleProductDebounced$, ({ action, dispatch }) => {
    const { id } = action.productData;
    dispatch(fetchProduct(id, true));
  });

  /** Visible product is no more available */
  subscribe(visibleProductNotFound$, ({ action, dispatch }) => {
    dispatch(showModal({
      confirm: null,
      dismiss: 'modal.ok',
      title: 'modal.title_error',
      message: 'product.no_more_found',
      params: {
        name: action.productData.name,
      },
    }));
    dispatch(historyPop());
    dispatch(expireProductById(action.productData.id));
  });

  subscribe(productRelationsReceived$, ({ dispatch, getState, action }) => {
    const { hash } = action;
    const productIds = getProductRelationsByHash(hash)(getState());

    dispatch(fetchProductsById(productIds));
  });

  /**
   * Expire products after checkout, fetch updated data
   */
  subscribe(checkoutSucceeded$, ({ dispatch, action }) => {
    const { products } = action;

    const productIds = products.map(p => p.product.id);
    productIds.forEach(id => dispatch(expireProductById(id)));

    dispatch(fetchProductsById(productIds));
  });
}
455326
public function actionShow(int $id)
    {

        $this->trigger(self::EVENT_BEFORE_SHOW, $this->getViewedProductEvent($id));

        $product = Product::find()
            ->where(['show' => true, 'id' => $id, 'status' => Product::STATUS_SUCCESS])
            ->one();

        if (!empty($product)) {

            $this->setSeoData($product);

            $this->trigger(self::EVENT_AFTER_SHOW);

            return $this->render('show', [
                'product' => $product,
                'cart' => new CartForm(),
                'defaultCombination' => Combination::find()->where([
                    'product_id' => $id,
                    'default' => true
                ])->one()
            ]);
        } else throw new NotFoundHttpException();
    }
809028
public function getProduct()
    {
        if ($this->product) {
            return $this->product;
        }

        if ($this->subject && $product = $this->subject->getProduct()) {
            $this->product = $product;

            return $product;
        }

        $product_id = $this->getRequest()->get('product_id') ?: $this->getRequest()->get('productId');
        if ($product_id) {
            $product = $this->getConfigurationPool()->getContainer()->get('sylius.repository.product')->find($product_id);
            if (!$product) {
                throw new \Exception(sprintf('Unable to find Product with id : %s', $product_id));
            }
            $this->product = $product;

            return $product;
        }

        return null;
    }
1006555
public function uploadAction(Product $product)
    {
        if (!$product) {
            throw $this->createNotFoundException('Unable to find Product entity.');
        }

        $productService = $this->get('amulen.shop.product');
        $response = $productService->uploadImage($product);

        $httpResponse = Response::HTTP_BAD_REQUEST;

        if ($response['upload_ok'] != 0) {
            $path = $response['target_file'];
            $em = $this->getDoctrine()->getManager();
            $mediaTypeRepository = $em->getRepository(MediaType::class);

            $mediaType = $mediaTypeRepository->findOneBy([
                'name' => 'image'
            ]);

            $media = new Media();
            $name = basename($_FILES["file"]["name"]);
            $slugName = strtolower(str_replace(' ','-',$name));
            $media->setName($slugName);
            $media->setPath($path);
            $media->setMediaType($mediaType);
            $em->persist($media);

            $galleryItem = new GalleryItem();
            $gallery = $product->getMediaGallery();
            $gallery->addGalleryItem($galleryItem);
            $galleryItem->setGallery($gallery);
            $galleryItem->setMedia($media);
            $position = $gallery->getGalleryItems()->count() + 1;
            $galleryItem->setPosition($position);

            $em->persist($galleryItem);
            $em->flush();
            $httpResponse = Response::HTTP_OK;
        }

        if ($response['upload_ok'] == 2) {
            $httpResponse = Response::HTTP_BAD_REQUEST;
        }

        return new JsonResponse($response['message'], $httpResponse);
    }
514729
public function showAction($featureId, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

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

        /** @var FeatureValue $entity */
        $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id);

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

        $deleteForm = $this->createDeleteForm($featureId, $id);

        return array(
            'entity'      => $entity,
            'feature'   => $feature,
            'delete_form' => $deleteForm->createView(),
        );
    }
168209
public function indexProduct($product_id)
    {
        $this->setProduct($product_id);
        $this->setMetaIndexProduct();
        $this->setTitleIndexProduct();
        $this->setBreadcrumbIndexProduct();
        $this->setHtmlFilterIndexProduct();

        $this->setData('product', $this->data_product);

        $this->setDataSummaryIndexProduct();
        $this->setDataImagesIndexProduct();
        $this->setDataCartFormIndexProduct();
        $this->setDataRatingWidgetIndexProduct();

        $this->setDataDescriptionIndexProduct();
        $this->setDataAttributesIndexProduct();
        $this->setDataReviewsIndexProduct();
        $this->setDataRecentIndexProduct();
        $this->setDataRelatedIndexProduct();
        $this->setDataBundledIndexProduct();

        $this->setJsIndexProduct();
        $this->outputIndexProduct();
    }
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(),
        );
    }
879634
public function showAction($slug)
    {
        $securityContext = $this->container->get('security.authorization_checker');
        $question        = $this->getQuestionRepository()->findOneBySlug($slug);

        if (!$question || (!$question->isPublic() && !$securityContext->isGranted('ROLE_EDITOR'))) {
            throw $this->createNotFoundException('question not found');
        }

        return $this->render(
            'GenjFaqBundle:Question:show.html.twig',
            array(
                'question' => $question
            )
        );
    }