src/Controller/ProductController.php line 334

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Category;
  4. use App\Entity\CompareParameterValue;
  5. use App\Entity\CompareProduct;
  6. use App\Entity\Language;
  7. use App\Entity\Product;
  8. use App\Entity\ProductLangParam;
  9. use App\Entity\ProductParameterValue;
  10. use App\Entity\ProductParameterValueGroup;
  11. use App\Entity\ProductPrice;
  12. use App\Entity\ProductPriceVariants;
  13. use App\Form\Type\ProductSearchFiltersType;
  14. use App\Form\Type\SampleOrderType;
  15. use App\Helper\VeltisControllerTrait;
  16. use App\Repository\ArticleRepository;
  17. use App\Repository\AvailabilityRepository;
  18. use App\Repository\BannerRepository;
  19. use App\Repository\CategoryRepository;
  20. use App\Repository\FurnitureTypeRepository;
  21. use App\Repository\HelplineHoursRepository;
  22. use App\Repository\NewsRepository;
  23. use App\Repository\ProductCommentRepository;
  24. use App\Repository\ProductParameterRepository;
  25. use App\Repository\ProductParameterValueGroupRepository;
  26. use App\Repository\ProductParameterValueRepository;
  27. use App\Repository\ProductPriceVariantsRepository;
  28. use App\Repository\ProductRepository;
  29. use App\Repository\WorkingHoursRepository;
  30. use App\Services\CompareManager;
  31. use App\Services\FacebookApiConversion;
  32. use App\Services\PasswordProtectedService;
  33. use App\Services\ProductCommentManager;
  34. use App\Services\ProductManager;
  35. use Doctrine\ORM\NoResultException;
  36. use Knp\Component\Pager\PaginatorInterface;
  37. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  38. use Symfony\Component\HttpFoundation\Cookie;
  39. use Symfony\Component\HttpFoundation\JsonResponse;
  40. use Symfony\Component\HttpFoundation\Request;
  41. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  42. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  43. use Symfony\Component\Routing\Annotation\Route;
  44. use Symfony\Component\HttpFoundation\Response;
  45. use Symfony\Component\Translation\TranslatorInterface;
  46. class ProductController extends AbstractController
  47. {
  48.     use VeltisControllerTrait;
  49.     /**
  50.      * @Route("/{slug}/{id}/p/{sub}", name="product", defaults={"sub"=null})
  51.      */
  52.     public function indexAction(Request $requestHelplineHoursRepository $helpLineHoursRepositoryProductRepository $productRepositoryProductManager $productManagerProductPriceVariantsRepository $productPriceVariantsRepositoryTranslatorInterface $translatorProductParameterValueRepository $productParameterValueRepositoryCompareManager $compareManagerPasswordProtectedService $passwordProtectedServiceProductCommentManager $productCommentManagerFacebookApiConversion $facebookApiConversion)
  53.     {
  54.         if ($passwordProtectedService->isPasswordProtected()) {
  55.             return $this->redirectToRoute('password_protected');
  56.         }
  57.         try {
  58.             $product $productRepository->getSingle($request->attributes->get('id'), $request->getLocale())->getQuery()->getSingleResult();
  59.         } catch (\Exception $e) {
  60.             throw new NotFoundHttpException();
  61.         }
  62.         $helplineHours $helpLineHoursRepository->getForCurrentDay($request->getLocale())->getQuery()->getOneOrNullResult();
  63.         $language $this->resolveLanguage($request->getLocale());
  64.         /** @var $productEntity Product */
  65.         $productEntity $this->em()->getRepository('App:Product')->find($request->attributes->get('id'));
  66.         if ($productEntity->getDeletedBy()) {
  67.             throw new NotFoundHttpException();
  68.         }
  69.         if ($request->attributes->get('slug') !== $productEntity->translate($request->getLocale())->getSlug()) {
  70.             return $this->redirect($this->generateUrl('product', ['id'=>$productEntity->getId(), 'slug'=>$productEntity->translate($request->getLocale())->getSlug()]), 301);
  71.         }
  72.         $pricing $productManager->generatePricing($productEntity$request->getLocale());
  73.         $priceVariants $productPriceVariantsRepository->getGroupVariantsForProduct($productEntity$request->getLocale())->getQuery()->getResult();
  74.         $family = [];
  75.         if ($product[0]->getProductFamily()) {
  76.             $family $productRepository->getProductFamily($product[0], $request->getLocale())->getQuery()->getResult();
  77.         }
  78.         $recommendations $productRepository->searchStore(['prodIds'=>$productEntity->getRecommendationsIds($request->getLocale()), 'locale'=>$request->getLocale()])->getQuery()->getResult();
  79.         $similarColors $productRepository->searchStore(['prodIds'=>$productEntity->getSimilarColorsIds(), 'locale'=>$request->getLocale()])->getQuery()->getResult();
  80.         $variantsArray = [];
  81.         $groupCounter = [];
  82.         /** @var $priceVariant ProductPriceVariants */
  83.         foreach ($priceVariants as $priceVariant) {
  84.             if ($priceVariant->getProductPrice() and $priceVariant->getProductPrice()->getActive() and $priceVariant->getProductPrice()->getLanguage()->getLocaleShort() == $request->getLocale()) {
  85.                 $group $priceVariant->getParameterValueGroup();
  86.                 $pp $priceVariant->getProductPrice();
  87.                 if ($pp->getProduct()->getId() != $priceVariant->getProduct()->getId()) {
  88.                     continue;
  89.                 }
  90.                 $idx $group->getId();
  91.                 $paramIdx $group->getParameter()->getId();
  92.                 $variantsArray[$idx]['parameter'] = $group->getParameter();
  93.                 $variantsArray[$idx]['group'] = $group;
  94.                 if (isset($groupCounter[$paramIdx])) {
  95.                     $groupCounter[$paramIdx] = $groupCounter[$paramIdx] + 1;
  96.                 } else {
  97.                     $groupCounter[$paramIdx] = 1;
  98.                 }
  99.                 $variantsArray[$idx]['values'] = $productParameterValueRepository->getValuesForGroup($group$request->getLocale())->getQuery()->getResult();
  100.             }
  101.         }
  102.         $productPrices $this->em()->getRepository('App:ProductPrice')->findBy(['active'=>1'product'=>$productEntity'language'=>$language'deletedBy'=>null], ['price'=>'ASC']);
  103.         $firstParamValues $productManager->findFirstParams($productPrices$request->getLocale());
  104.         $parameterValues $productManager->getParameterValues($productPrices$request->getLocale());
  105.         $vat $this->em()->getReference('App:ProductVat'$product['vatId']);
  106.         $productManager->addLastViewRecord($productEntity);
  107.         $images = [
  108.             'pl' => ['return14'=>'/images/ico/14_dni.svg''onMarket'=>'/images/ico/pl_15_lat.svg''freeDelivery'=>'/v2/ico/free_delivery_ico.png'],
  109.             'sk' => ['return14'=>'/images/ico/14_dni.svg''onMarket'=>'/images/ro/sk_17_rokov.svg''freeDelivery'=>'/images/icon_0eur.svg'],
  110.             'cz' => ['return14'=>'/images/ico/14_dni.svg''onMarket'=>'/images/ico/cz_5_let.svg''freeDelivery'=>'/images/icon_0kc.svg'],
  111.             'ro' => ['price' => '/images/ico/icon_cena.svg''return14'=>'/images/ico/14_dni.svg''onMarket'=>'/images/ro/ro_17_ani.svg''outlet'=>'/images/ro/box_outlet_ro.jpg''prod24h'=>'/images/ro/box_24h-01.jpg''szok'=>'/images/ro/oferta_speciale_box.jpg''freeDelivery'=>'/images/ro/icon_olei_ro.svg'],
  112.         ];
  113.         $buyCheaperLP $this->em()->getRepository('App:LandingPage')->findOneBy(['deletedBy'=>null'language'=>$language'specialForBuyCheaper'=>true]);
  114.         $minPrice $productManager->getMinPrice($productEntity$language);
  115.         $minPriceNet $productManager->getMinPriceNetto($productEntity$language);
  116.         /* RO constant marker */
  117.         $markerConstant $this->em()->getRepository('App:Marker')->find(788);
  118.         $omnibus $productManager->prepareOmnibusPrice($productEntity$language$minPriceNet);
  119.         if ($omnibus) {
  120.             $product['omnibusPrice'] = $omnibus;
  121.         }
  122.         if ($request->getLocale() != 'pl') {
  123.             $facebookApiConversion->createFbEvent('ViewContent');
  124.         }
  125.         $comments $productCommentManager->getComments($productEntity$language);
  126.         $rating $productCommentManager->getAverageRating($productEntity$language);
  127.         return $this->render('frontend/product/product.html.twig', [
  128.             'rating' => $rating,
  129.             'similarColors' => $similarColors,
  130.             'comments' => $comments,
  131.             'language' => $language,
  132.             'markerConstant' => $markerConstant,
  133.             'product' => $product[0],
  134.             'staticImages' => $images,
  135.             'buyCheaperLP' => $buyCheaperLP,
  136.             'locale'=>$request->getLocale(),
  137.             'compareIds' => $compareManager->getIdsCompareProducts(),
  138.             'pricing' => $pricing,
  139.             'groupCounter' => $groupCounter,
  140.             'firstParamValues' => $firstParamValues,
  141.             'minPrice'=>$minPrice,
  142.             'priceNetto' => $minPriceNet,
  143.             'parameterValues' => $parameterValues,
  144.             'versions' => json_encode($productManager->findVersionsForJson($firstParamValues$translator$request$productPrices), JSON_HEX_QUOT),
  145.             'equipments' => $productManager->findEquipment($translator$productEntity$language),
  146.             'isEquipment' => count($productEntity->getActiveEquipment()),
  147.             'recommendations' => $recommendations,
  148.             'priceVariants' => $priceVariants,
  149.             'productPrices' => $productPrices,
  150.             'productEntity' => $productEntity,
  151.             'variantsArray' => $variantsArray,
  152.             'vat' => $vat,
  153.             'family' => $family,
  154.             'helplineHours' => $helplineHours,
  155.             'productData' => $product,
  156.         ]);
  157.     }
  158.     /**
  159.      * @Route("/product/load-next-param/{id}", name="loadNextParam")
  160.      */
  161.     public function ajaxLoadNextParamAction(Request $requestProductRepository $productRepositoryProductManager $productManagerTranslatorInterface $translatorProductPriceVariantsRepository $productPriceVariantsRepository) {
  162.         try {
  163.             $product $productRepository->getSingle($request->attributes->get('id'), $request->getLocale())->getQuery()->getSingleResult();
  164.         } catch (\Exception $e) {
  165.             throw new NotFoundHttpException();
  166.         }
  167.         $language $this->resolveLanguage($request->getLocale());
  168.         $productPrices $this->em()->getRepository('App:ProductPrice')->findBy(['product'=>$product[0], 'language'=>$language'deletedBy'=>null'active'=>1]);
  169.         $allParameters $productManager->getParameterValues($productPrices$request->getLocale());
  170.         $nextParam 0;
  171.         $params $request->request->get('params');
  172.         //$params = [['param'=>8, 'value'=>2935], ['param'=>9, 'value'=>142], ['param'=>23, 'value'=>0], ['param'=>75, 'value'=>0]];
  173.         //$params = [['param'=>8, 'value'=>2935], ['param'=>9, 'value'=>0], ['param'=>55, 'value'=>0]];
  174.         $c 0;
  175.         $chosenParams = [];
  176.         foreach ($params as $key => $row) {
  177.             $c $c+1;
  178.             $chosenParams[] = ['parameterId'=>$row['param'], 'value'=>$row['value']];
  179.             if ($row['value'] == 0) { //if next value is zero -> then parameter is not set; so this is our next param to handle
  180.                 $nextParam $row['param'];
  181.                 break;
  182.             }
  183.         }
  184.         $countChosenParams 0;
  185.         foreach ($chosenParams as $chosenParam) {
  186.             if ($chosenParam['value'] > 0) {
  187.                 $countChosenParams $countChosenParams 1;
  188.             }
  189.         }
  190.         $nextParameterEntity false;
  191.         /**
  192.          * @var  $key integer - id of the parameter
  193.          * @var  $value
  194.          */
  195.         foreach ($allParameters as $key => $value) {
  196.             if ($nextParam == $key) {
  197.                 $nextParameterEntity $value->getParameter();
  198.             }
  199.         }
  200.         $productPrices $this->em()->getRepository('App:ProductPrice')->findBy(['active'=>1'product'=>$product[0], 'deletedBy'=>null], ['price'=>'ASC']);
  201.         $passedVariants = [];
  202.         /** @var $productPrice ProductPrice */
  203.         foreach ($productPrices as $productPrice) {
  204.             if ($productPrice->getLanguage()->getLocale() == $request->getLocale() and $productPrice->getDeletedBy() === null) {
  205.                 $variantValues = [];
  206.                 $variantValuesIds = [];
  207.                 foreach ($productPrice->getVariants() as $variant) {
  208.                     if ($variant->getParameterValue() and !in_array($variant->getParameterValue()->getId(), $variantValuesIds)) {
  209.                         $variantValues[] = $variant->getParameterValue();
  210.                         $variantValuesIds[] = $variant->getParameterValue()->getId();
  211.                     }
  212.                     if ($variant->getParameterValueGroup() && $variant->getParameterValueGroup()->getDeletedBy() === null) {
  213.                         /** @var $variantValue ProductParameterValue */
  214.                         foreach ($variant->getParameterValueGroup()->getVisibleValues() as $variantValue) {
  215.                             if (!in_array($variantValue->getId(), $variantValuesIds)) {
  216.                                 $variantValues[] = $variantValue;
  217.                                 $variantValuesIds[] = $variantValue->getId();
  218.                             }
  219.                         }
  220.                     }
  221.                 }
  222.                 $pass 1;
  223.                 foreach ($chosenParams as $chosenParam) {
  224.                     if (!in_array($chosenParam['value'], $variantValuesIds) and $chosenParam['value'] > 0) {
  225.                         $pass 0;
  226.                         break;
  227.                     }
  228.                 }
  229.                 if ($pass) {
  230.                     $passedVariants[] = $productPrice;
  231.                 }
  232.             }
  233.         }
  234.         $showPrice 1;
  235.         $returnVariant 0;
  236.         if ($countChosenParams === count($allParameters)-1) {
  237.             $returnVariant 1;
  238.         }
  239.         $return = [];
  240.         //$values = [];
  241.         //$values[] = ['id'=>1, 'src'=>'', 'desc'=>'', 'variant'=>''];
  242.         //$return[] = ['id'=>1, 'name'=>'--wybierz--', 'surcharge'=>' ', 'description'=>'', 'images'=>$values];
  243.         //now choose all values associated with next param - based on passed variants
  244.         /** @var $productPrice ProductPrice */
  245.         $variantGroupIds = [];
  246.         if ($nextParameterEntity === false) {
  247.             return new JsonResponse([]);
  248.         }
  249.         foreach ($passedVariants as $productPrice) {
  250.             $variantsQuery $productPriceVariantsRepository->getByProductPrice($productPrice)->getQuery()->getResult();
  251.             /** @var $variant ProductPriceVariants */
  252.             foreach ($variantsQuery as $variant) {
  253.                 if ($variant->getDeletedBy() === null and $variant->getParameterValueGroup() and $variant->getParameterValueGroup()->getDeletedBy() === null and $variant->getParameter()->getId() == $nextParameterEntity->getId() and !in_array($variant->getParameterValueGroup()->getId(), $variantGroupIds)) {
  254.                     $values = [];
  255.                     $values[] = ['id'=>0'src'=>0'desc'=>'''variant'=>''];
  256.                     foreach ($variant->getParameterValueGroup()->getVisibleValues() as $value) {
  257.                         if ($value->getDeletedBy() === null) {
  258.                             $values[] = [
  259.                                 'id' => $value->getId(),
  260.                                 'src' => '/images/parameters/'.$value->getImageName(),
  261.                                 'desc' => $value->getName(),
  262.                                 'variant' => ($returnVariant) ? $variant->getId() : '',
  263.                             ];
  264.                         }
  265.                     }
  266.                     /** @var $language Language */
  267.                     $language $productPrice->getProduct()->getLangParamByLocale($request->getLocale())->getLanguage();
  268.                     $price $productManager->getPrice($product[0], $language$variant->getId());
  269.                     $variantGroupIds[] = $variant->getParameterValueGroup()->getId();
  270.                     $return[] = [
  271.                         'id' => $variant->getParameterValueGroup()->getId(),
  272.                         'name' => $variant->getParameterValueGroup()->getName(),
  273.                         'surcharge' => str_replace("."$variant->getProductPrice()->getCurrency()->getSeparator(), $price).' '.$variant->getProductPrice()->getCurrency()->getSign(),
  274.                         'description' => $translator->trans('parameter_choose_helper', [], 'store'$request->getLocale()),
  275.                         'images' => $values,
  276.                         'currencySeparator'=>$variant->getProductPrice()->getCurrency()->getSeparator(),
  277.                         'net' => $variant->getProductPrice()->getPrice()
  278.                     ];
  279.                 }
  280.             }
  281.         }
  282.         $arr $return;
  283.         if (empty($arr)) {
  284.             $values = [];
  285.             $values[] = ['id'=>1'src'=>'''desc'=>'''variant'=>''];
  286.             $return[] = ['id'=>1'currencySeparator'=>',''name'=>$translator->trans('choose', [], 'store'$request->getLocale()), 'net'=>' ''surcharge'=>' ''description'=>'''images'=>$values];
  287.             return new JsonResponse($return);
  288.         }
  289.         return new JsonResponse($arr);
  290.     }
  291.     /**
  292.      * @Route("/product/tkaninyOpisy/{id}", name="textileDescription")
  293.      */
  294.     public function textileDescriptionAction(Request $requestProductRepository $productRepositoryPaginatorInterface $paginator)
  295.     {
  296.         /** @var $group ProductParameterValueGroup */
  297.         $group $this->em()->getRepository('App:ProductParameterValueGroup')->find($request->attributes->get('id'));
  298.         if (!$group) {
  299.             return $this->redirectToRoute('homepage');
  300.         }
  301.         $products $productRepository->getForParameterGroup($group$request->getLocale())->getQuery()->getResult();
  302.         $pagination $paginator->paginate($products$request->query->getInt('page'1)/*page number*/20, ['wrap-queries'=>true]);
  303.         return $this->render('frontend/product/textileDescription.html.twig', [
  304.             'group' => $group,
  305.             'language' => $this->resolveLanguage($request->getLocale()),
  306.             'products' => $pagination,
  307.         ]);
  308.     }
  309.     public function getCompareManager() {
  310.         return $this->get('compare.manager');
  311.     }
  312.     /**
  313.      * @Route("/product/compare/add-to-compare", name="add_to_compare")
  314.      */
  315.     public function addAction(Request $requestCompareManager $compareManagerSessionInterface $session) {
  316.         $product $request->request->get('product');
  317.         $em $this->getDoctrine()->getManager();
  318.         /** @var $productEntity Product */
  319.         $productEntity $em->getRepository('App:Product')->find($product);
  320.         $cart_session $session->get('cart_session');
  321.         $response = new Response(count($compareManager->getIdsCompareProducts()));
  322.         if (!$cart_session) {
  323.             $rand substr(md5(uniqid(mt_rand(), true)) , 036);
  324.             $response->headers->setCookie(new Cookie("cart_session"$randtime()+14*24*60*60));
  325.             $this->get('session')->set('cart_session'$rand);
  326.             $this->get('session')->set('compare'$rand);
  327.             $cart_session $rand;
  328.             $add $compareManager->create();
  329.             $add->setProduct($productEntity);
  330.             $add->setSession($cart_session);
  331.             $response->setContent(count($compareManager->getIdsCompareProducts()));
  332.             return new $response;
  333.         }
  334.         $add $compareManager->create();
  335.         $add->setProduct($productEntity);
  336.         $add->setSession($cart_session);
  337.         $compareManager->save($add);
  338.         return new Response(count($compareManager->getIdsCompareProducts()));
  339.     }
  340.     /**
  341.      * @Route("/product/compare/remove-from-compare", name="remove_compare")
  342.      */
  343.     public function removeAction(Request $requestCompareManager $compareManager) {
  344.         $product $request->request->get('product');
  345.         $productEntity $this->em()->getRepository('App:Product')->find($product);
  346.         $cart_session $request->getSession()->get('cart_session');
  347.         $find $this->em()->getRepository('App:CompareProduct')->findOneBy(array('product'=>$productEntity'session'=>$cart_session));
  348.         $this->em()->remove($find);
  349.         $this->em()->flush();
  350.         return new Response(count($compareManager->getIdsCompareProducts()));
  351.     }
  352.     /**
  353.      * @Route("/product/compare/results", name="compare_products_summary")
  354.      */
  355.     public function compareResultsAction(Request $requestCompareManager $compareManagerProductRepository $productRepository) {
  356.         $compareProducts $compareManager->getCompareProducts();
  357.         /** @var $compareProduct CompareProduct */
  358.         foreach ($compareProducts as $compareProduct) {
  359.             $product $compareProduct->getProduct();
  360.             $compareProduct->details $productRepository->getSingle([$product->getId()], $request->getLocale())->getQuery()->getResult();
  361.             #sprawdzamy czy wszystkie dodane parametry dla kategorii mają swoje odpowiedniki wartości (nawet puste) dla danego produktu
  362.             $parameters $product->getMainCategory()->getCompareParameters();
  363.             /*
  364.             foreach ($parameters as $param) {
  365.                 $check = $this->em()->getRepository('App:CompareParameterValue')->findOneBy(array('parameter'=>$param, 'category'=>$product->getMainCategory(), 'product'=>$product));
  366.                 if (!is_object($check)) {
  367.                     $add = new CompareParameterValue();
  368.                     $add->setCategory($product->getMainCategory());
  369.                     $add->setProduct($product);
  370.                     $add->setParameter($param);
  371.                     $this->em()->persist($add);
  372.                     $this->em()->flush();
  373.                 }
  374.             }
  375.             */
  376.         }
  377.         return $this->render('frontend/product/compareResults.html.twig', array('locale'=>$request->getLocale(), 'language' => $this->resolveLanguage($request->getLocale()), 'compareProducts'=>$compareProducts));
  378.     }
  379.     /**
  380.      * @Route("/product/sample/order", name="sample_order")
  381.      */
  382.     public function sampleOrderAction(Request $request, \Swift_Mailer $mailerTranslatorInterface $translator) {
  383.         $form $this->createForm(SampleOrderType::class);
  384.         $form->handleRequest($request);
  385.         $send 0;
  386.         $title $translator->trans('email_title_order_sample', [], 'store'$request->getLocale());
  387.         /** @var $language Language */
  388.         $language $this->resolveLanguage($request->getLocale());
  389.         if ($form->isSubmitted()) {
  390.             if ($form->isValid()) {
  391.                     $fromField 'f';
  392.                     if ($language->getId() == 2) {
  393.                         $fromField 'A';
  394.                     }
  395.                     if ($language->getId() == 3) {
  396.                         $fromField 'P';
  397.                     }
  398.                     if ($language->getId() == 4) {
  399.                         $fromField 'J';
  400.                     }
  401.                     $html $this->renderView('frontend/email/sampleOrder.html.twig', ['formData' => $form->getData()]);
  402.                     $recipients = ['to'=>['email'=>$language->getAdminStoreEmail()]];
  403.                     //$recipients = ['to'=>['email'=>'krzysiek.gaudy@gmail.com']];
  404.                     $content = [
  405.                         'fromField'=>['fromFieldId'=>$fromField],
  406.                         'subject'=>$title,
  407.                         'content'=>['html'=>$html'plain'=>''],
  408.                         'recipients'=>$recipients,
  409.                     ];
  410.                     $ch curl_init();
  411.                     $body json_encode($content);
  412.                     curl_setopt($chCURLOPT_URL"https://api3.getresponse360.pl/v3/transactional-emails");
  413.                     curl_setopt($chCURLOPT_RETURNTRANSFER1);
  414.                     curl_setopt($chCURLOPT_POSTFIELDS$body);
  415.                     curl_setopt($chCURLOPT_POST1);
  416.                     $headers = array();
  417.                     $headers[] = "Content-Type: application/json";
  418.                     $headers[] = "X-Auth-Token: api-key gs478s9uv59n5ekulmpmgn5p0uqpepbn";
  419.                     $headers[] = "X-Domain: echairs.eu";
  420.                     curl_setopt($chCURLOPT_HTTPHEADER$headers);
  421.                     $result curl_exec($ch);
  422.                     curl_close ($ch);
  423.                     $json json_decode($resulttrue);
  424.                     $send 1;
  425.             }
  426.         }
  427.         return $this->render('frontend/product/sampleOrder.html.twig', [
  428.             'language' => $this->resolveLanguage($request->getLocale()),
  429.             'send' => $send,
  430.             'form' => $form->createView(),
  431.         ]);
  432.     }
  433.     /**
  434.      * @Route("/product/load-gallery/{id}", name="load_gallery_image")
  435.      */
  436.     public function loadGalleryAction(Request $request) {
  437.         $photo $this->em()->getRepository('App:ProductPhoto')->find($request->attributes->get('id'));
  438.         return $this->render('frontend/product/photoModal.html.twig', [
  439.             'photo' => $photo,
  440.         ]);
  441.     }
  442. }