src/Controller/ShopController.php line 44

Open in your IDE?
  1. <?php
  2. /*
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. namespace App\Controller;
  8. use App\Model\DefaultMarca;
  9. use App\Service\CartService;
  10. use App\Service\ProductService;
  11. use App\Service\ShopService;
  12. use Symfony\Component\HttpFoundation\Cookie;
  13. use App\Twig\Extension\ProductExtension;
  14. use Pimcore\Model\DataObject;
  15. use Pimcore\Controller\FrontendController;
  16. use Pimcore\Model\DataObject\Folder;
  17. use Pimcore\Model\Document;
  18. use Pimcore\Twig\Extension\Templating\HeadTitle;
  19. use Symfony\Component\HttpFoundation\JsonResponse;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. use App\Model\DefaultProduct;
  25. use Pimcore\Config;
  26. use App\Model\ShopCategory;
  27. use App\Service\HelperService;
  28. use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
  29. use Pimcore\Bundle\EcommerceFrameworkBundle\FilterService\Helper;
  30. use Pimcore\Bundle\EcommerceFrameworkBundle\FilterService\ListHelper;
  31. use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ProductListInterface;
  32. use Pimcore\Model\DataObject\FilterDefinition;
  33. use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
  34. use Knp\Component\Pager\Pagination\SlidingPagination;
  35. use Knp\Component\Pager\PaginatorInterface;
  36. use App\Templating\Helper\BreadcrumbHelperService;
  37. use Symfony\Component\Security\Core\User\UserInterface;
  38. use App\Model\Customer;
  39. /**
  40.  * ShopController
  41.  */
  42. class ShopController extends FrontendController
  43. {
  44.     /**
  45.      * onKernelController
  46.      */
  47.     public function onKernelController(FilterControllerEvent $event)
  48.     {
  49.         parent::onKernelController($event);
  50.         //$this->view->category = ShopCategory::getById($event->getRequest()->get('category'));
  51.     }
  52.     /**
  53.      * defaultAction
  54.      */
  55.     public function defaultAction(
  56.         Request $request,
  57.         HelperService $helperService
  58.     )
  59.     {
  60.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  61.         //  $this->checkAccess($request);
  62.         // $this->setCookieTemplate();
  63.         $params['unique'] = $helperService->generateUniqueCode();
  64.     }
  65.     #[Route('/categories-filter',name'categoriesFilter')]
  66.     public function categoriesFilter(
  67.         UserInterface $user null,
  68.         Request $request,
  69.         HeadTitle $headTitleHelper,
  70.         BreadcrumbHelperService $breadcrumbHelperService,
  71.         Factory $ecommerceFactory,
  72.         HelperService $helperService,
  73.         ListHelper $listHelper,
  74.         PaginatorInterface $paginator,
  75.     ){
  76.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  77.         //needed to make sure category filter filters for active category
  78.         $params['parentCategoryIds'] = $params['currentCategory'] ?? null;
  79.         $category ShopCategory::getById($params['currentCategory']);
  80.         $params['category'] = $category;
  81.         if($category){
  82.             $headTitleHelper($category->getTitle());
  83.             $breadcrumbHelperService->enrichCategoryPage($category);
  84.         }
  85.         // create product list
  86.         $indexService $ecommerceFactory->getIndexService();
  87.         $products $indexService->getProductListForCurrentTenant();
  88.         $products->setVariantMode(ProductListInterface::VARIANT_MODE_HIDE);
  89.         $products->addCondition("productstatus NOT IN ('new','decatelogized','for_delete') OR productstatus IS NULL"'productstatus');
  90.         $params["products"] = $products;
  91.         // load current filter
  92.         if ($category) {
  93.             $filterDefinition $category->getFilterdefinition();
  94.             $trackingManager Factory::getInstance()->getTrackingManager();
  95.             $trackingManager->trackCategoryPageView($category->getTitle(), null);
  96.         }
  97.         if ($request->get('filterdefinition') instanceof FilterDefinition) {
  98.             $filterDefinition $request->get('filterdefinition');
  99.         }
  100.         if (empty($filterDefinition)) {
  101.             $filterDefinition Config::getWebsiteConfig()->get('fallbackFilterdefinition');
  102.         }
  103.         $environment $ecommerceFactory->getEnvironment();
  104.         $environment->setCurrentAssortmentTenant('OptimizedMysql');
  105.         // create and init filter service
  106.         $filterService $ecommerceFactory->getFilterService();
  107.         $listHelper->setupProductList($filterDefinition$products$params$filterServicetrue);
  108.         $params["filterService"] = $filterService;
  109.         $params["filterDefinition"] = $filterDefinition;
  110.         //init pagination
  111.         $paginator $paginator->paginate(
  112.             $products,
  113.             $request->get('page'1),
  114.             $filterDefinition->getPageLimit()
  115.         );
  116.         $params["paginator"] = $paginator;
  117.         $params['paginationVariables'] = $paginator->getPaginationData();
  118.         //check if layout should not be included
  119.         $params["showLayout"] = ($request->get('noLayout')) ? false true;
  120.         $params["listViewStyle"] = (array_key_exists('listViewStyle'$params)) ? $params['listViewStyle'] : 'grid';
  121.         $params["unique"] = $helperService->generateUniqueCode();
  122.         // track product impressions
  123.         $trackingManager $ecommerceFactory->getTrackingManager();
  124.         foreach ($paginator as $product) {
  125.             $trackingManager->trackProductImpression($product);
  126.         }
  127.         $params['categories'] = $this->getCategories();
  128.         $params['brands'] = $this->getMarcas();
  129.         return $this->render('Shop/filters/productSubCategories.html.twig',$params);
  130.     }
  131.     public function listAction(
  132.         UserInterface $user null,
  133.         Request $request,
  134.         HeadTitle $headTitleHelper,
  135.         BreadcrumbHelperService $breadcrumbHelperService,
  136.         Factory $ecommerceFactory,
  137.         HelperService $helperService,
  138.         ListHelper $listHelper,
  139.         PaginatorInterface $paginator,
  140.     ):Response
  141.     {
  142.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  143.         $brandName $request->get('brandname');
  144.         $brandId $request->get('brand');
  145.         $isSeoFriendlyUrl preg_match('/productos\/marcas/'$brandName);
  146.         if ($isSeoFriendlyUrl) {
  147.             $params["marca"] = $params["brand"];
  148.         }
  149.             //needed to make sure category filter filters for active category
  150.         $params['parentCategoryIds'] = $params['category'] ?? null;
  151.         //current Category for subFilter Proposes
  152.         $params['currentCategory'] = $params['category'] ?? null;
  153.         $category ShopCategory::getById($params['category'] ?? null);
  154.         $params['category'] = $category;
  155.         if($category){
  156.             $headTitleHelper($category->getTitle());
  157.             $breadcrumbHelperService->enrichCategoryPage($category);
  158.         }
  159.         // create product list
  160.         $indexService $ecommerceFactory->getIndexService();
  161.         $products $indexService->getProductListForCurrentTenant();
  162.         $products->setVariantMode(ProductListInterface::VARIANT_MODE_HIDE);
  163.         $products->addCondition("productstatus NOT IN ('new','decatelogized','for_delete') OR productstatus IS NULL"'productstatus');
  164.         $params["products"] = $products;
  165.         // load current filter
  166.         if ($category) {
  167.             $filterDefinition $category->getFilterdefinition();
  168.             $trackingManager Factory::getInstance()->getTrackingManager();
  169.             $trackingManager->trackCategoryPageView($category->getTitle(), null);
  170.         }
  171.         if ($request->get('filterdefinition') instanceof FilterDefinition) {
  172.             $filterDefinition $request->get('filterdefinition');
  173.         }
  174.         if (empty($filterDefinition)) {
  175.             $filterDefinition Config::getWebsiteConfig()->get('fallbackFilterdefinition');
  176.         }
  177.         $environment $ecommerceFactory->getEnvironment();
  178.         $environment->setCurrentAssortmentTenant('OptimizedMysql');
  179.         // create and init filter service
  180.         $filterService $ecommerceFactory->getFilterService();
  181.         $listHelper->setupProductList($filterDefinition$products$params$filterServicetrue);
  182.         $params["filterService"] = $filterService;
  183.         $params["filterDefinition"] = $filterDefinition;
  184.         //init pagination
  185.         $paginator $paginator->paginate(
  186.             $products,
  187.             $request->get('page'1),
  188.             $filterDefinition->getPageLimit()
  189.         );
  190.         $params["paginator"] = $paginator;
  191.         $params['paginationVariables'] = $paginator->getPaginationData();
  192.         //check if layout should not be included
  193.         $params["showLayout"] = ($request->get('noLayout')) ? false true;
  194.         $params["listViewStyle"] = (array_key_exists('listViewStyle'$params)) ? $params['listViewStyle'] : 'grid';
  195.         $params["unique"] = $helperService->generateUniqueCode();
  196.         // track product impressions
  197.         $trackingManager $ecommerceFactory->getTrackingManager();
  198.         foreach ($paginator as $product) {
  199.             $trackingManager->trackProductImpression($product);
  200.         }
  201.         //subCategories Logic
  202.         if ($params['currentCategory']){
  203.                 if ($params['currentCategory'] == 21822){//Awlcraft G-H LINE
  204.                     return $this->redirect('/es/Pinturas/Acabados/Awlgrip-GH-Line/GH-Line-Solidos_c21836/awlgrip-top-coat-g-h-line_p2580');
  205.                 }
  206.                 elseif ($params['currentCategory'] == 21828){//Alcraft Se E Line metalizados
  207.                     return $this->redirect('/es/Pinturas/Acabados/Awlcraft-Se/Awlcraft-Se-E-Line-Metalizados_c21828/awlcraft-se-e-line_p2336');
  208.                 }
  209.                 elseif ($params['currentCategory'] == 21829){//Alcraft Se L Line metalizados
  210.                     return $this->redirect('/es/Pinturas/Acabados/Awlcraft-Se/Awlcraft-Se-l-Line-Solidos_c21829/awlcralf-se-l-line_p21578');
  211.                 }
  212.                 elseif ($params['currentCategory'] == 21825){//Alcraft 2000 Metalizados
  213.                     return $this->redirect('/es/Pinturas/Acabados/Awlcraft-2000/Awlcraft-2000-Metalizados_c21825/awlcraft-2000-metallics_p21474');
  214.                 }
  215.                 elseif ($params['currentCategory'] == 21824){//Alcraft 2000 Solidos
  216.                     return $this->redirect('/es/Pinturas/Acabados/Awlcraft-2000/Awlcraft-2000-solidos_c21824/awlcraft-2000-topcoat_p21665');
  217.                 }
  218.                 elseif ($params['currentCategory'] == 21832){//International  Perfection
  219.                     return $this->redirect('/es/Pinturas/Acabados/Perfection-Topcoat/Perfection_c21832/perfection_p898');
  220.                 }
  221.             return $this->render('Shop/listing.html.twig'$params);
  222.         }
  223.         //end subCategories Logic
  224.         return $this->render('Shop/listing.html.twig'$params);
  225.     }
  226.     public function detailAction(
  227.         Request $request,
  228.         ProductService $productService
  229.     ): Response
  230.     {
  231.         $user $this->getUser();
  232.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  233.         $product DefaultProduct::getById($params['product']);
  234.         if ($user) {
  235.             //User ID to get product discount
  236.             $params['userIdSage'] = $user->getIdSage();
  237.         }
  238.         if ($product) {
  239.             if ($product->getType() == DataObject\AbstractObject::OBJECT_TYPE_VARIANT) {
  240.                 $parentObj DefaultProduct::getById($product->getParentId());
  241.                 if ($product->getClassId() == $parentObj->getClassId()) {
  242.                     $product $parentObj;
  243.                 }
  244.             }
  245.             $marca $product->getMarcaObject();
  246.             if ($marca) {
  247.                 $params['marca'] = array($marca->getId());
  248.             }
  249.             $params['product'] = $product;
  250.         }
  251.         $params['filterBtnActive'] = true;
  252.         $params['company'] = DataObject\Company::getById(415);
  253.         $lastVisitedProductsIds json_decode($request->cookies->get('last_visited_products''[]'), true);
  254.         $productID $params['product']->getId();
  255.         if (!in_array($productID$lastVisitedProductsIds)) {
  256.             // Add the ID of the currently visited product to the beginning of the array
  257.             array_unshift($lastVisitedProductsIds$productID);
  258.         }
  259.         $lastVisitedProductsIds array_slice($lastVisitedProductsIds011);
  260.         $lastVisitedProducts = [];
  261.         foreach ($lastVisitedProductsIds as $productID) {
  262.             $lastVisitedProducts[] = DefaultProduct::getById($productID);
  263.         }
  264.         $params['lastVisitedProducts'] = $lastVisitedProducts;
  265.         // Get Related Product for product bundle
  266.         $relatedProducts $productService->getRelatedProducts($product);
  267.         $params['relatedProducts'] = $relatedProducts;
  268.         $response $this->render('Shop/ProductDetails/productDetail.html.twig'$params);
  269.         $cookie = new Cookie('last_visited_products'json_encode($lastVisitedProductsIds), time() + 86400); // 86400 segundos = 1 día
  270.         $response->headers->setCookie($cookie);
  271.         return $response;
  272.     }
  273.     /**
  274.      * searchAction
  275.      * @Route("/search")
  276.      */
  277.     public function searchAction(
  278.         Request $request,
  279.         ProductExtension $productExtension
  280.     )
  281.     {
  282.         $products = [];
  283.         $productList Factory::getInstance()->getIndexService()->getProductListForTenant('OptimizedMysql');
  284.         $productList->addCondition("productstatus NOT IN ('new','decatelogized','for_delete') OR productstatus IS NULL "'productstatus');
  285.         //Remove extra spaces between words to avoid affecting matches.
  286.         $params['keyword'] = trim(preg_replace('/\s+/'' '$request->get('input')));
  287.         $params['isEmpty'] = false;
  288.         if (key_exists('keyword'$params)) {
  289.             $productList->addQueryCondition($params['keyword'], 'search');
  290.             if ($productList->count() === 0){
  291.                 $productList->resetConditions();
  292.                 $query "bsncode LIKE '%" $params['keyword'] . "%'";
  293.                 $productList->addCondition($query'bsncode');
  294.             }
  295.         }
  296.         $language $request->query->get('lang');
  297.         $count 0;
  298.         $maxProducts 75// Maximum number of products allowed in $products
  299.         foreach ($productList as $product) {
  300.             $auxParent $product->getParent();
  301.             if (!$auxParent instanceof Folder){
  302.                 $product $product->getParent();
  303.             }
  304.             $auxParent = new \stdClass();
  305.             $auxParent->id $product->getId();
  306.             $auxParent->name $product->getName();
  307.             $auxParent->bsnCode $product->getBsncode();
  308.             $found false;
  309.             foreach ($products as $existingProduct) {
  310.                 if ($existingProduct['id'] == $auxParent->id) {
  311.                     $found true;
  312.                     break;
  313.                 }
  314.             }
  315.             if (!$found) {
  316.                 // Convert both the product name and the search term to their form without accents using iconv()
  317.                 $productNameWithoutAccents iconv('UTF-8''ASCII//TRANSLIT//IGNORE'$auxParent->name);
  318.                 $searchTermWithoutAccents iconv('UTF-8''ASCII//TRANSLIT//IGNORE'$params['keyword']);
  319.                 if (strcasecmp(trim($productNameWithoutAccents), $searchTermWithoutAccents) == 0) { // Check if product name matches search term exactly
  320.                     unset($products);
  321.                     $products[] = [
  322.                         'id' => $product->getId(),
  323.                         'name' => $product->getName(),
  324.                         'brand' => $product->getMarca(),
  325.                         'item' => DefaultProduct::getById($product->getId())
  326.                     ];
  327.                     break; // Stop iterating if exact match is found
  328.                 }
  329.                 else if ($count $maxProducts) { // Check if the maximum limit has been reached
  330.                     $products[] = [
  331.                         'id' => $product->getId(),
  332.                         'name' => $product->getName(),
  333.                         'brand' => $product->getMarca(),
  334.                         'item' => DefaultProduct::getById($product->getId()),
  335.                     ];
  336.                     $count++;
  337.                 } else {
  338.                     break; // Stop iterating if maximum limit has been reached
  339.                 }
  340.             }
  341.         }
  342.         foreach ($products as &$product) {
  343.             $productName strtolower($product['name']);
  344.             $distance levenshtein($params['keyword'], $productName);
  345.             $score 100 $distance// Asigna un puntaje inversamente proporcional a la distancia
  346.             $product['score'] = $score;
  347.         }
  348.         // Paso 3: Ordenar los productos según el puntaje
  349.         usort($products, function($a$b) {
  350.             return $b['score'] - $a['score'];
  351.         });
  352.         $params['products'] = $products;
  353.         $params['lang'] = $language;
  354.         return $this->render('layout/includes/navbar-serach-suggestion-items.html.twig'$params);
  355.     }
  356.     /**
  357.      * searchdocumentAction
  358.      *
  359.      * @param Request $request
  360.      * @param Factory $ecommerceFactory
  361.      * @param HelperService $helperService,
  362.      * @param ListHelper $listHelper
  363.      * @param PaginatorInterface $paginator
  364.      * @return void
  365.      */
  366.     public function searchdocumentAction(
  367.         Request $request,
  368.         Factory $ecommerceFactory,
  369.         HelperService $helperService,
  370.         ListHelper $listHelper,
  371.         PaginatorInterface $paginator
  372.     )
  373.     {
  374.         //    $this->checkAccess($request);
  375.         //    $this->setCookieTemplate();
  376.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  377.         $limit $params['limit'];
  378.         $params["orderBy"] = "name#ASC";
  379.         $actPage $params['page'];
  380.         if (empty($actPage)) {
  381.             $actPage 1;
  382.         }
  383.         if ($request->get('filterdefinition') instanceof \Pimcore\Model\DataObject\FilterDefinition) {
  384.             $filterDefinition $request->get('filterdefinition');
  385.         }
  386.         if (empty($filterDefinition)) {
  387.             $filterDefinition \Pimcore\Config::getWebsiteConfig()->fallbackFilterdefinition;
  388.         }
  389.         $this->view->filterDefinitionObject $filterDefinition;
  390.         if (empty($limit)) {
  391.             $limit $filterDefinition->getPageLimit();
  392.         }
  393.         $productList Factory::getInstance()->getIndexService()->getProductListForCurrentTenant();
  394.         $productList->addCondition("productstatus NOT IN ('new','decatelogized','for_delete') OR productstatus IS NULL"'productstatus');
  395.         if (empty($params['keyword'])) {
  396.             $params['keyword'] = $params['searchwords'];
  397.         }
  398.         if (key_exists('keyword'$params)) {
  399.             //  foreach (explode(' ', $params['keyword']) as $term) {
  400.             $productList->addQueryCondition($params['keyword'], 'search');
  401.             // }
  402.         }
  403.         $filterService Factory::getInstance()->getFilterService();
  404.         $params['filterService'] = $filterService;
  405.         $params['products'] = $productList;
  406.         $params['searchwords'] = $params['keyword'];
  407.         /** @var SlidingPagination $paginator */
  408.         $paginator $paginator->paginate(
  409.             $productList,
  410.             $request->get('page'1),
  411.             $limit
  412.         );
  413.         $params["paginator"] = $paginator;
  414.         $params['paginationVariables'] = $paginator->getPaginationData();
  415.         $params['actPage'] = $actPage;
  416.         $params['limit'] = $limit;
  417.         $params['unique'] = $helperService->generateUniqueCode();
  418.     }
  419.     /**
  420.      * cuantapinturanecesarioresultAction
  421.      *
  422.      * @param Request $request
  423.      * @param Factory $ecommerceFactory
  424.      * @param HelperService $helperService,
  425.      * @param ListHelper $listHelper
  426.      * @param PaginatorInterface $paginator
  427.      *
  428.      * @return void
  429.      */
  430.     public function cuantapinturanecesarioresultAction(
  431.         Request $request,
  432.         Factory $ecommerceFactory,
  433.         HelperService $helperService,
  434.         ListHelper $listHelper,
  435.         PaginatorInterface $paginator
  436.     )
  437.     {
  438.         //$this->checkAccess($request);
  439.         //$this->setCookieTemplate();
  440.         $params array_merge($request->query->all(), $request->attributes->all(), $request->request->all());
  441.         $limit $params['limit'];
  442.         $params["orderBy"] = "name#ASC";
  443.         $actPage $params['page'];
  444.         if (empty($actPage)) {
  445.             $actPage 1;
  446.         }
  447.         $resultado = array();
  448.         $resultado["tipo-embarcacion"] = $params["radio_1"];
  449.         if (preg_match("/^mo/i"$params["radio_1"], $params["radio_1"])) {
  450.             $resultado["tipo-embarcacion"] = $resultado["tipo-embarcacion"] . $params["radio_2"];
  451.         }
  452.         $resultado["base-embarcacion"] = $params["radio_3"];
  453.         $resultado["dimension-eslora"] = $params["value1"];
  454.         $resultado["dimension-calado"] = $params["value2"];
  455.         $resultado["dimension-manga"] = $params["value3"];
  456.         $resultado["resultado-litre"] = round($params["value_1"], 2);
  457.         $this->view->resultado $resultado;
  458.         if (!key_exists("calculvariant"$params)) {
  459.             if (empty($params["calculvariant"])) {
  460.                 $params["calculvariant"] = $params["value_hidden"];
  461.             }
  462.         }
  463.         if ($request->get('filterdefinition') instanceof \Pimcore\Model\DataObject\FilterDefinition) {
  464.             $filterDefinition $request->get('filterdefinition');
  465.         }
  466.         if (empty($filterDefinition)) {
  467.             $filterDefinition \Pimcore\Config::getWebsiteConfig()->resultcuantapinturaFilterdefinition;
  468.         }
  469.         $params['filterDefinition'] = $filterDefinition;
  470.         if (empty($limit)) {
  471.             $limit $filterDefinition->getPageLimit();
  472.         }
  473.         // create product list
  474.         $products Factory::getInstance()->getIndexService()->getProductListForCurrentTenant();
  475.         $products->setVariantMode(ProductListInterface::VARIANT_MODE_INCLUDE_PARENT_OBJECT);
  476.         $products->addCondition("productstatus NOT IN ('new','decatelogized','for_delete') OR productstatus IS NULL"'productstatus');
  477.         $products->addCondition("calculvariant LIKE '%#" $params["value_hidden"] . "#%'"'calculvariant');
  478.         $params['products'] = $products;
  479.         // create and init filter service
  480.         $filterService Factory::getInstance()->getFilterService();
  481.         Helper::setupProductList($filterDefinition$products$params$this->view$filterServicetrue);
  482.         $params['filterService'] = $filterService;
  483.         /** @var SlidingPagination $paginator */
  484.         $paginator $paginator->paginate(
  485.             $products,
  486.             $request->get('page'1),
  487.             $limit
  488.         );
  489.         $params["paginator"] = $paginator;
  490.         $params['paginationVariables'] = $paginator->getPaginationData();
  491.         $params['actPage'] = $actPage;
  492.         $params['limit'] = $limit;
  493.         $params['unique'] = $helperService->generateUniqueCode();
  494.     }
  495.     /**
  496.      * setCookieTemplate
  497.      *
  498.      * @return void
  499.      */
  500.     public function setCookieTemplate()
  501.     {
  502.         $cookieListener $this->get(\Pimcore\Bundle\CoreBundle\EventListener\Frontend\CookiePolicyNoticeListener::class);
  503.         $cookieListener->loadTemplateFromResource("@App/Resources/views/Misc/cookie-policy-bsn-template.html");
  504.     }
  505.     /**
  506.      * checkAccess
  507.      *
  508.      * @param Request $request
  509.      * @return void
  510.      */
  511.     private function checkAccess(Request $request)
  512.     {
  513.         if (!(($request->query->get('pimcore_preview') == "true") || ($request->query->get('pimcore_editmode') == "true"))) {
  514.             //  $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  515.         }
  516.     }
  517.     /**
  518.      * @Route("/ajax_productDetail_getStock", name="ajax_productDetail_getStock")
  519.      */
  520.     public function productDetailGetStockAjaxAction(
  521.         Request $request,
  522.         ShopService $shopService,
  523.     ): JsonResponse
  524.     {
  525.         $product DefaultProduct::getById($request->get('id'));
  526.         $params = [];
  527.         if (!is_null($product)) {
  528.             $params['deliveryTime'] = $product->getPlazoentregaprovedor();
  529.             $params['stock']['total'] = $shopService->getStock($product->getBsncode());
  530.             $params['stock']['warehouse'] = $shopService->getStockByWarehouse($product->getBsncode());
  531.         }
  532.         return new JsonResponse($params);
  533.     }
  534.     /**
  535.      * @Route("/ajax_productDetail_new_asset", name="ajax_productDetail_new_asset")
  536.      */
  537.     public function productDetailnewAsset(
  538.         Request $request,
  539.     ){
  540.         $idProduct $request->get('id');
  541.         $product DefaultProduct::getById($idProduct);
  542.         $param['product'] = $product;
  543.         $param['test'] = $idProduct;
  544.         return $this->render('Shop/includes/newAsset.html.twig',$param);
  545.     }
  546.     /**
  547.      * @Route("/ajax_productDetail_info", name="ajax_productDetail_info")
  548.      */
  549.     public function productDetailInfo(
  550.         Request $request,
  551.     ){
  552.         $idProduct $request->get('newId');
  553.         $product DefaultProduct::getById($idProduct);
  554.         $param['deliveryTime'] = $product->getPlazoentregaprovedor();
  555.         return new JsonResponse($param);
  556.     }
  557.     /**
  558.      * @Route("/ajax_variant_info", name="ajax_variant_info")
  559.      */
  560.     public function variantInfo(
  561.         Request $request,
  562.         ShopService $shopService,
  563.         UserInterface $usernull
  564.     ){
  565.         /** @var \Pimcore\Model\DataObject\Customer $user */
  566.         $variant DefaultProduct::getById($request->get('id'));
  567.         $priceWithDiscount $shopService->getProductDiscount($variant->getBsncode(),$user->getIdSage());
  568.         $params['price'] = $variant->getPrice();
  569.         $params['bsnCode'] = $variant->getBsncode();
  570.         $params['stock']['total'] = $shopService->getStock($params['bsnCode']);
  571.         $params['stock']['warehouse'] = $shopService->getStockByWarehouse($params['bsnCode']);
  572.         $params['deliveryTime'] = $variant->getPlazoentregaprovedor();
  573.         $params['priceWithDiscount'] = $priceWithDiscount;
  574.         return new JsonResponse($params);
  575.     }
  576.     protected function getCategories(): DataObject\ProductCategory\Listing
  577.     {
  578.         $categories = new DataObject\ProductCategory\Listing();
  579.         $categories->setUnpublished(false);
  580.         $categories->setOrderKey("order");
  581.         $categories->setCondition('o_parentId = ?', [10]);
  582.         $categories->load();
  583.         return $categories;
  584.     }
  585.     protected function getMarcas(): DataObject\ProductMarca\Listing
  586.     {
  587.         $marcas = new DataObject\ProductMarca\Listing();
  588.         $marcas->setUnpublished(false);
  589.         $marcas->setOrderKey("order");
  590.         $marcas->load();
  591.         return $marcas;
  592.     }
  593.     #[Route('/ajax_productDetail_getBrandName',name:'ajax-productDetail-getBrandName')]
  594.     public function ajax_productDetail_getBrandName(Request $request): Response
  595.     {
  596.         $product DefaultProduct::getById($request->get('id'));
  597.         return $this->json($product->getMarcaObject()->getName());
  598.     }
  599. }