src/Kiwi/EshopBundle/Service/EshopGatewayHandle.php line 638

Open in your IDE?
  1. <?php
  2. namespace Kiwi\EshopBundle\Service;
  3. use Kiwi\EshopBundle\Entity\Product;
  4. use Kiwi\EshopBundle\Entity\ProductHolders;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class EshopGatewayHandle {
  7.     var $controller null;
  8.     protected $languages;
  9.     /**
  10.      * @var \Doctrine\ORM\EntityManager
  11.      */
  12.     private $em;
  13.     /**
  14.      * @var \Kiwi\PageBundle\Twig\PageExtensions
  15.      */
  16.     private $pageExtensions;
  17.     /**
  18.      * @var \Kiwi\EshopBundle\Service\EshopProductsHandle
  19.      */
  20.     private $eshopProductsHandle;
  21.     /**
  22.      * @var \Kiwi\SearchBundle\Service\SearchHandle
  23.      */
  24.     private $searchHandle;
  25.     /**
  26.      * @var \Kiwi\EshopBundle\Service\EshopCategoriesHandle
  27.      */
  28.     private $eshopCategoriesHandle;
  29.     /**
  30.      * @var \Kiwi\EshopBundle\Service\EshopParamsHandle
  31.      */
  32.     private $eshopParamsHandle;
  33.     /**
  34.      * @var \Kiwi\EshopBundle\Service\EshopProducersHandle
  35.      */
  36.     private $eshopProducersHandle;
  37.     /**
  38.      * @var \Kiwi\EshopBundle\Service\EshopAttachementsHandle
  39.      */
  40.     private $eshopAttachementsHandle;
  41.     public function __construct(\Doctrine\ORM\EntityManager $em,
  42.                                 \Kiwi\LanguagesBundle\Service\LanguagesHandle $languages,
  43.                                 \Kiwi\PageBundle\Twig\PageExtensions $pageExtensions,
  44.                                 \Kiwi\EshopBundle\Service\EshopProductsHandle $eshopProductsHandle,
  45.                                 \Kiwi\SearchBundle\Service\SearchHandle $searchHandle,
  46.                                 \Kiwi\EshopBundle\Service\EshopCategoriesHandle $eshopCategoriesHandle,
  47.                                 \Kiwi\EshopBundle\Service\EshopParamsHandle $eshopParamsHandle,
  48.                                 \Kiwi\EshopBundle\Service\EshopProducersHandle $eshopProducersHandle,
  49.                                 \Kiwi\EshopBundle\Service\EshopAttachementsHandle $eshopAttachementsHandle) {
  50.         $this->em $em;
  51.         $this->languages $languages;
  52.         $this->pageExtensions $pageExtensions;
  53.         $this->eshopProductsHandle $eshopProductsHandle;
  54.         $this->searchHandle $searchHandle;
  55.         $this->eshopCategoriesHandle $eshopCategoriesHandle;
  56.         $this->eshopParamsHandle $eshopParamsHandle;
  57.         $this->eshopProducersHandle $eshopProducersHandle;
  58.         $this->eshopAttachementsHandle $eshopAttachementsHandle;
  59.     }
  60.     public function setController($controller) {
  61.         $this->controller $controller;
  62.         return $this;
  63.     }
  64.     public function getCategories($configRequest $request) {
  65.         $main_category explode('/',$request->getUri()); $main_category end($main_category);
  66.         return $this->eshopCategoriesHandle->getCategoriesBySeoName($main_category);
  67.     }
  68.     public function getParam($configRequest $request) {
  69.         $code null;
  70.         if(isset($config['method_params'])) {
  71.             if(isset($config['method_params'][0])) {
  72.                 $code $config['method_params'][0];
  73.             }
  74.         }
  75.         if(!$config) {
  76.             return false;
  77.         }
  78.         $param $this->eshopParamsHandle->getCustomParamByCode($code);
  79.         $list $this->eshopParamsHandle->getCustomParamList($param->getId());
  80.         foreach ($list as $l) {
  81.             $l->full_link $this->controller->get('page_twig_extension')->kpathFunction(12$config['lang']);
  82.             $l->full_link .= $l->getCode();
  83.         }
  84.         return array(
  85.             'param' => $param,
  86.             'list' => $list
  87.         );
  88.         return $code;
  89.     }
  90.     private function getUrlCategory(Request $request){
  91.         $uri explode('?'$request->getRequestUri());
  92.         $uri explode('/'$uri[0]);
  93.         return $this->eshopCategoriesHandle->getCategoryBySeoName(end($uri));
  94.     }
  95.     private function getUrlKolekce(Request $request){
  96.         $uri explode('?'$request->getRequestUri());
  97.         $uri explode('/'$uri[0]);
  98.         return $this->eshopParamsHandle->getCustomListParamByCode(4end($uri));
  99.     }
  100.     private function getUrlProducer(Request $request){
  101.         $uri explode('?'$request->getRequestUri());
  102.         $uri explode('/'$uri[0]);
  103.         return $this->eshopProducersHandle->getProducerByCode(end($uri));
  104.     }
  105.     private function getUrlStyl(Request $request){
  106.         $uri explode('?'$request->getRequestUri());
  107.         $uri explode('/'$uri[0]);
  108.         return $this->eshopParamsHandle->getCustomListParamByCode(9end($uri));
  109.     }
  110.     private function getQQdataCategory(Request $request) {
  111.         $category $this->getUrlCategory($request);
  112.         $qq $request->get('qq');
  113.         if($category) {
  114.             $qq[0][$category->getId()] = 'on';
  115.         }
  116.         return $qq;
  117.     }
  118.     private function getQQdataKolekce(Request $request) {
  119.         $kolekce $this->getUrlKolekce($request);
  120.         $qq $request->get('qq');
  121.         if($kolekce) {
  122.             $qq[$kolekce->getCustomParamId()][$kolekce->getId()] = 'on';
  123.         }
  124.         return $qq;
  125.     }
  126.     private function getQQdataStyle(Request $request) {
  127.         $styl $this->getUrlStyl($request);
  128.         if($styl) {
  129.             $qq[$styl->getCustomParamId()][$styl->getId()] = 'on';
  130.         }
  131.         return $qq;
  132.     }
  133.     public function getFilterData($configRequest $request) {
  134.         $context null;
  135.         if(isset($config['method_params'])) {
  136.             if(isset($config['method_params'][0])) {
  137.                 $context $config['method_params'][0];
  138.             }
  139.         }
  140.         switch ($context) {
  141.             default:
  142.                 $category $this->getUrlCategory($request);
  143.                 $qq $this->getQQdataCategory($request);
  144.             break;
  145.             case 'style':
  146.                 //$category = $this->getUrlCategory($request);
  147.                 $category null;
  148.                 $qq $this->getQQdataStyle($request);
  149.             break;
  150.             /*
  151.             case 'material':
  152.                 $qq = $this->getQQdataCategory($request);
  153.             break;
  154.             case 'kolekce':
  155.                 $qq = $this->getQQdataKolekce($request);
  156.             break;
  157.             */
  158.         }
  159.         $fillingProducts $this->getProducts($config$request);
  160.         $fillingProductsAgreagted = [];
  161.         $fillingProductsCategoriesAgreagted = [];
  162.         foreach($fillingProducts['result']['data'] as $ag_product) {
  163.             //if($ag_product['id'] == 185)
  164.             //    return $ag_product;
  165.             //categories filler
  166.             if(isset($ag_product['master_category'])) {
  167.                 if(isset($ag_product['master_category']['id'])) {
  168.                     $fillingProductsCategoriesAgreagted[] = $ag_product['master_category']['id'];
  169.                 }
  170.             }
  171.             //params filler
  172.             foreach($ag_product['params_full'] as $ag_product_param) {
  173.                 //declare if not defined
  174.                 if(!isset($fillingProductsAgreagted[$ag_product_param['id']])) {
  175.                     $fillingProductsAgreagted[$ag_product_param['id']] = [];
  176.                 }
  177.                 //agregate enabled values
  178.                 if(count($ag_product_param['current']) >= 1) {
  179.                     foreach($ag_product_param['current'] as $ag_product_param_current) {
  180.                         if(!in_array($ag_product_param_current$fillingProductsAgreagted[$ag_product_param['id']])) {
  181.                             $fillingProductsAgreagted[$ag_product_param['id']][] = $ag_product_param_current;
  182.                         }
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.         $fillingProductsCategoriesAgreagted array_unique($fillingProductsCategoriesAgreagted);
  188.         $ret = [];
  189.         if($category) {
  190.             $cpl $this->eshopParamsHandle->getCustomParamsCategoryFiltered($category);
  191.         } else {
  192.             $cpl $this->eshopParamsHandle->getCustomParams();
  193.         }
  194.         foreach($cpl as $opt){
  195.             if($opt->getIsVisible()) {
  196.                 $options $this->eshopParamsHandle->getCustomParamList($opt->getId(), (isset($fillingProductsAgreagted[$opt->getId()])) ? $fillingProductsAgreagted[$opt->getId()] : []);
  197.                 if(count($options) >= 1) {
  198.                     $ret[] = array(
  199.                         'id' => $opt->getId(),
  200.                         'name' => $opt->getName(),
  201.                         'code' => $opt->getCode(),
  202.                         'type' => $opt->getType(),
  203.                         'options' => $options
  204.                     );
  205.                 }
  206.             }
  207.         }
  208.         if(is_null($category) or $category->getOptFour()) {
  209.             $ret[] = array(
  210.                 'id' => 0,
  211.                 'name' => '<?xml version="1.0" encoding="utf-8" ?><data><cz><![CDATA[Material]]></cz></data>',
  212.                 'code' => 'category',
  213.                 'type' => "list-multiple",
  214.                 'options' => $this->eshopCategoriesHandle->getCategories(0false'cz'$fillingProductsCategoriesAgreagted)
  215.             );
  216.         }
  217.         /*
  218.          *     "id" => 2
  219.     "name" => "<?xml version="1.0" encoding="utf-8" ?><data><cz><![CDATA[Styl]]></cz></data>"
  220.     "code" => "style"
  221.     "type" => "list-multiple"
  222.     "options" => array:14 [▶]
  223.   ]
  224.          * */
  225.         return array(
  226.             'data' => $ret,
  227.             'qq' => $qq,
  228.             'test' => $fillingProductsAgreagted,
  229.             'test2' => $fillingProducts['result']['data']
  230.         );
  231.     }
  232.     public function getProductsByProducer($configRequest $request) {
  233.         $producer $this->getUrlProducer($request);
  234.         if(!$producer) {
  235.             return false;
  236.         }
  237.         $search = clone $this->searchHandle;
  238.         $search->generateRn();
  239.         $search->setRequest($request)
  240.             ->setFrom($this->eshopCategoriesHandle->repo_categories,'c')
  241.             ->setJoin('c.product''p')
  242.             ->setJoin('p.producer''pr')
  243.             //->setJoin('h.article', 'a')
  244.             ->addWhere('p.is_holder = true')
  245.             ->addWhere('p.eshop_id = '.$this->eshopProductsHandle->getEshop()->getId())
  246.             ->addWhere('pr.id = '.$producer->getId())
  247.             //->setSearchTextLike('p.transport_code', 'Kód')
  248.             //->setSearchTextLike('a.name', 'Jméno')
  249.             //->addWhere('p.eshop_id = '.$this->get('eshop_products_handle')->getEshop()->getId())
  250.             //->setSearchSelect('u.order_state')
  251.             //->setSearchTextLike('us.username', 'Uživatelské jméno')
  252.             //->setSearchTextLike('a.content', 'Jméno společnosti')
  253.             //->setSearchDateRange('u.created_time', 'Vytvořena')
  254.             ->setSortMask(array())
  255.             ->setRpp(99999);
  256.         //return $search->getResult();
  257.         $search->groupBy('p.id');
  258.         $holders_rs $search->getResult();
  259.         //print_r($holders_rs['config']['query']); exit;
  260.         $_holders = [];
  261.         foreach ($holders_rs['data'] as $product) {
  262.             //$_holders[] = $product->getProduct();
  263.             //$_holders[] = $this->processHolder($product->getProduct());
  264.             $_holders[] = $this->eshopProductsHandle->getProductReturnArrayBlock($product->getProduct(), 'cz', []);
  265.         }
  266.         $holders_rs['data'] = $_holders;
  267.         return [
  268.             'producer' => $producer,
  269.             'search' => $search,
  270.             'form' => $search->getForm(),
  271.             'result' => $holders_rs,
  272.             'result_type' => 'holders'
  273.             //'paginator' => $this->controller->get('templating')->render('KiwiPaginatorBundle:Kbox:buttons.html.twig',array('paginator' => $holders_rs['config']['paginator'])),
  274.         ];
  275.     }
  276.     public function getProducts($configRequest $request) {
  277.         $context null;
  278.         if(isset($config['method_params'])) {
  279.             if(isset($config['method_params'][0])) {
  280.                 $context $config['method_params'][0];
  281.             }
  282.         }
  283.         $category null;
  284.         switch ($context) {
  285.             default:
  286.                 $category $this->getUrlCategory($request);
  287.                 $qq $this->getQQdataCategory($request);
  288.             break;
  289.             case 'style':
  290.                 //$category = $this->getUrlCategory($request);
  291.                 $category null;
  292.                 $qq $this->getQQdataStyle($request);
  293.             break;
  294.             /*
  295.             case 'material':
  296.                 $qq = $this->getQQdataCategory($request);
  297.             break;
  298.             case 'kolekce':
  299.                 $qq = $this->getQQdataKolekce($request);
  300.             break;
  301.             */
  302.         }
  303.         if($qq) {
  304.             $products = [];
  305.             $required_score count($qq);
  306.             foreach ($qq as $param_id => $opts) {
  307.                 if($param_id == 0) {
  308.                     $promoted = [];
  309.                     foreach (array_keys($opts) as $_opt) {
  310.                         foreach ($this->eshopCategoriesHandle->getCategoryProducts($_optfalse) as $_product) {
  311.                             $pid $_product->getProduct()->getId();
  312.                             if(!in_array($pid$promoted)) {
  313.                                 $products[$pid] = (isset($products[$pid])) ? ($products[$pid]+1) : 1;
  314.                                 $promoted[] = $pid;
  315.                             }
  316.                         }
  317.                     }
  318.                 } else {
  319.                     $promoted = [];
  320.                     foreach ($this->eshopParamsHandle->getCustomCoParamsByParamId($param_id) as $_opt) {
  321.                         //print_r([$_opt->getProductId()]);
  322.                         $pid $_opt->getProductId();
  323.                         $intersection array_intersect(
  324.                             array_keys(
  325.                                 $opts
  326.                             ),
  327.                             array_keys(
  328.                                 unserialize($_opt->getParamValue())
  329.                             )
  330.                         );
  331.                         if(count($intersection) >= 1) {
  332.                             if(!in_array($pid$promoted)) {
  333.                                 $products[$pid] = (isset($products[$pid])) ? ($products[$pid]+1) : 1;
  334.                                 $promoted[] = $pid;
  335.                             }
  336.                         }
  337.                     }
  338.                 }
  339.             }
  340.             $products_temp $products;
  341.             $products = [];
  342.             foreach ($products_temp as $product_key => $product_score) {
  343.                 if($product_score == $required_score) {
  344.                     $products[] = $product_key;
  345.                 }
  346.             }
  347.             //this is not needed at this context
  348.             /*
  349.             $products_rs = [];
  350.             //foreach (array_slice($products, 0, 99999) as $product_id) {
  351.             foreach ($products as $product_id) {
  352.                 $products_rs[] = $this->eshopProductsHandle->getProductReturnArrayBlock(
  353.                     $this->eshopProductsHandle->getProduct($product_id),
  354.                     $config['lang'],
  355.                     []
  356.                 );
  357.             }
  358.             */
  359. /*
  360.             $holders_rs = [];
  361.             foreach ($products as $product_id) {
  362.                 $product = $this->eshopProductsHandle->getProduct($product_id);
  363.                 if($product->getIsHidden() == false or is_null($product->getIsHidden())) {
  364.                     if($product->getIsDeleted() == false or is_null($product->getIsDeleted())) {
  365.                         if(!array_key_exists($product->getHolder()->getId(), $holders_rs)) {
  366.                             $holders_rs[$product->getHolder()->getId()] = $this->processHolder($product->getHolder());
  367.                         }
  368.                     }
  369.                 }
  370.             }
  371. */
  372.             $holders_rs = [];
  373.             foreach ($products as $product_id) {
  374.                 $product $this->eshopProductsHandle->getProduct($product_id);
  375.                 if($product->getIsHidden() == false or is_null($product->getIsHidden())) {
  376.                     if($product->getIsDeleted() == false or is_null($product->getIsDeleted())) {
  377.                         if(!array_key_exists($product->getId(), $holders_rs)) {
  378.                             //$holders_rs[$product->getId()] = $this->processHolder($product);
  379.                             $holders_rs[$product->getId()] = $this->eshopProductsHandle->getProductReturnArrayBlock($product'cz', []);
  380.                         }
  381.                     }
  382.                 }
  383.             }
  384.             return [
  385.                 //'search' => $search,
  386.                 //'form' => $search->getForm(),
  387.                 'qq' => $qq,
  388.                 //'result_products' => $products_rs,
  389.                 'result' => array('data' => $holders_rs),
  390.                 'result_type' => 'holders'
  391.                 //'paginator' => $this->controller->get('templating')->render('KiwiPaginatorBundle:Kbox:buttons.html.twig',array('paginator' => $holders_rs['config']['paginator'])),
  392.             ];
  393.         }
  394.         /*
  395.          *         $qb = $this->em->createQueryBuilder();
  396.         $qb->select('c')
  397.             ->from($phObj->repo_categories, 'c')
  398.             ->join('c.product', 'p')
  399.             ->where('c.category_id = :category_id')
  400.             ->andWhere('p.is_deleted = false')
  401.             ->andwhere('p.eshop_id = '.$phObj->getEshop()->getId())
  402.             ->setParameter('category_id', (int)$category_id)
  403.             ->setMaxResults(1000);
  404.         if(!$show_hidden) {
  405.             $qb->andWhere('p.is_hidden = false OR p.is_hidden IS NULL');
  406.         }
  407.          * */
  408.         $search = clone $this->searchHandle;
  409.         $search->generateRn();
  410.         $search->setRequest($request)
  411.             ->setFrom($this->eshopCategoriesHandle->repo_categories,'c')
  412.             ->setJoin('c.product''p')
  413.             ->setJoin('p.producer''pr')
  414.             //->setJoin('h.article', 'a')
  415.             ->addWhere('p.is_holder = true')
  416.             ->addWhere('p.eshop_id = '.$this->eshopProductsHandle->getEshop()->getId())
  417.             //->setSearchTextLike('p.transport_code', 'Kód')
  418.             //->setSearchTextLike('a.name', 'Jméno')
  419.             //->addWhere('p.eshop_id = '.$this->get('eshop_products_handle')->getEshop()->getId())
  420.             //->setSearchSelect('u.order_state')
  421.             //->setSearchTextLike('us.username', 'Uživatelské jméno')
  422.             //->setSearchTextLike('a.content', 'Jméno společnosti')
  423.             //->setSearchDateRange('u.created_time', 'Vytvořena')
  424.             ->setSortMask(array())
  425.             ->setRpp(99999);
  426.         if($category) {
  427.             $search->addWhere('c.category_id = '.$category->getId());
  428.         }
  429.         if($request->get('q')) {
  430.             $search->setSearchTextLike('a.name''Jméno');
  431.             $search->addWhere('
  432.                 p.code LIKE \'%'.addslashes($request->get('q')).'%\' OR
  433.                 pr.name LIKE \'%'.addslashes($request->get('q')).'%\' OR                
  434.                 p.name LIKE \'%'.addslashes($request->get('q')).'%\'
  435.             ');
  436.         }
  437.         /*
  438.         $search = clone $this->searchHandle;
  439.         $search->setRequest($request)
  440.                 ->setFrom('Kiwi\EshopBundle\Entity\ProductHolders','p')
  441.                 ->setJoin('p.article','a')
  442.                 ->setSearchTextLike('p.transport_code', 'Kód')
  443.                 ->setSearchTextLike('a.name', 'Jméno')
  444.                 //->addWhere('p.eshop_id = '.$this->get('eshop_products_handle')->getEshop()->getId())
  445.                 //->setSearchSelect('u.order_state')
  446.                 //->setSearchTextLike('us.username', 'Uživatelské jméno')
  447.                 //->setSearchTextLike('a.content', 'Jméno společnosti')
  448.                 //->setSearchDateRange('u.created_time', 'Vytvořena')
  449.                 ->setSortMask(array())
  450.                 ->setRpp(25);
  451.         if($request->get('q')) {
  452.             $search->addWhere('
  453.                 p.transport_code LIKE \'%'.addslashes($request->get('q')).'%\' OR
  454.                 a.name LIKE \'%'.addslashes($request->get('q')).'%\'
  455.             ');
  456.         }
  457.         */
  458.         //return $search->getResult();
  459.         $search->groupBy('p.id');
  460.         $holders_rs $search->getResult();
  461.         //print_r($holders_rs['config']['query']); exit;
  462.         $_holders = [];
  463.         foreach ($holders_rs['data'] as $product) {
  464.             //$_holders[] = $product->getProduct();
  465.             //$_holders[] = $this->processHolder($product->getProduct());
  466.             $_holders[] = $this->eshopProductsHandle->getProductReturnArrayBlock($product->getProduct(), 'cz', []);
  467.         }
  468.         $holders_rs['data'] = $_holders;
  469.         return [
  470.             'search' => $search,
  471.             'form' => $search->getForm(),
  472.             'result' => $holders_rs,
  473.             'result_type' => 'holders'
  474.             //'paginator' => $this->controller->get('templating')->render('KiwiPaginatorBundle:Kbox:buttons.html.twig',array('paginator' => $holders_rs['config']['paginator'])),
  475.         ];
  476.     }
  477.     public function getActionProducts($configRequest $request) {
  478.         return $this->eshopProductsHandle->findProducts('cz', array('action' => 1))['filtered'];
  479.     }
  480.     public function getCatalogues($configRequest $request) {
  481.         return $this->eshopAttachementsHandle->getAllCatalogues();
  482.     }
  483.     public function getProductsByStyle($configRequest $request) {
  484.     }
  485.     public function getProduct($configRequest $request) {
  486.         $uri explode('/'$request->getRequestUri());
  487.         $id end($uri); $id explode("?",$id); $id $id[0];
  488.         //search for holder
  489.         $search = clone $this->searchHandle;
  490.         $search->setRequest($request)
  491.                 ->setFrom('Kiwi\EshopBundle\Entity\Product','p')
  492.                 ->addWhere(sprintf("p.id = %d"$id))
  493.                 ->addWhere('p.is_holder = true')
  494.                 ->setSortMask(array())
  495.                 ->setRpp(1);
  496.         $holder $search->getResult();
  497.         $product null;
  498.         if(!isset($holder['data'][0])) {
  499.             //if holder not found try extrapolate from product
  500.             $search = clone $this->searchHandle;
  501.             $search->setRequest($request)
  502.                 ->setFrom('Kiwi\EshopBundle\Entity\Product','p')
  503.                 ->addWhere(sprintf("p.id = %d"$id))
  504.                 ->addWhere('p.is_holder = false')
  505.                 ->setSortMask(array())
  506.                 ->setRpp(1);
  507.             $product $search->getResult();
  508.             if(isset($product['data'][0])) {
  509.                 $product $product['data'][0];
  510.                 $holder['data'][0] = $product->getHolder();
  511.             }
  512.         }
  513.         if(!isset($holder['data'][0])) {
  514.             $product null;
  515.             //if holder not found try extrapolate from holder name
  516.             $search = clone $this->searchHandle;
  517.             $search->setRequest($request)
  518.                 ->setFrom('Kiwi\EshopBundle\Entity\ProductHolders','p')
  519.                 ->setJoin('p.article''a')
  520.                 ->addWhere('a.name LIKE \'%'.addslashes($id).'%\'')
  521.                 ->setSortMask(array())
  522.                 ->setRpp(1);
  523.             $holder $search->getResult();
  524.         }
  525.         if(!isset($holder['data'][0])) {
  526.             return false;
  527.         }
  528.         //return $this->eshopProductsHandle->getProductReturnArrayBlock($holder['data'][0], 'cz', []);
  529.         //return $holder['data'][0];
  530.         $out $this->processHolderExtended($holder['data'][0], 'cz'$product);
  531.         if(count($out['variants']) <= 0) {
  532.             //return false;
  533.         }
  534.         if(isset($out['id'])) {
  535.             if($config['response']) {
  536.                 $this->eshopProductsHandle->storeCookieProductReference($out['id'], $request$config['response']);
  537.             }
  538.         }
  539.         if(isset($out['id'])) {
  540.             $seotitle 'F.a.r.line - '.$out['name'];
  541.             $seodescription strip_tags($out['description']);
  542.             $seoimage $out['main_product_image'];
  543.             $this->controller->get('page_frontend_handle')->setPageMeta($seotitle,$seoimage,$seodescription);
  544.         }
  545.         return $out;
  546.     }
  547.     public function getProducers($configRequest $request) {
  548.         return $this->eshopProducersHandle->getProducers(null,truetrue);
  549.     }
  550.     public function getProducer($configRequest $request) {
  551.         $producer $this->getUrlProducer($request);
  552.         if(!$producer) {
  553.             return false;
  554.         }else{
  555.             $out $this->eshopProducersHandle->getProducers($producer,truetrue);
  556.             $seotitle 'F.a.r.line - '.$this->languages->getLangEntry($out->getName(), 'cz');
  557.             $seodescription strip_tags($out->getArticle()->getContent());
  558.             $seoimage '/cut-image-strict/640/480/'.$out->getImage()->getName().'.'.$out->getImage()->getExtension();
  559.             $this->controller->get('page_frontend_handle')->setPageMeta($seotitle,$seoimage,$seodescription);
  560.         }
  561.         return $this->eshopProducersHandle->getProducers($producer,truetrue);
  562.     }
  563.     private function processHolder(Product $holder$lang 'cz') {
  564.         return $this->eshopProductsHandle->getProductReturnArrayBlock($holder$lang, []);
  565.         return [
  566.             'id' => $holder->getId(),
  567.             'code' => $holder->getCode(),
  568.             'name' => $this->languages->getLangEntry($holder->getName(), $lang),
  569.             'images_id' => [
  570.                 'main' => ($holder->getArticle()->getImage()) ? $holder->getArticle()->getImage()->getId() : null
  571.             ],
  572.             'url' => [
  573.                 'detail' => $this->getHolderUrl($holder$lang)
  574.             ]
  575.         ];
  576.     }
  577.     private function processHolderExtended(Product $holder$lang 'cz'Product $active_product null) {
  578.         $data $this->processHolder($holder$lang);
  579.         $search = clone $this->searchHandle;
  580.             //->setRequest($request)
  581.         $search->setFrom('Kiwi\EshopBundle\Entity\Product','p')
  582.             ->addWhere(sprintf("p.holder_id = '%d'"$holder->getId()))
  583.             ->setSortMask(array())
  584.             ->setOrderBy('p.sort_num''ASC')
  585.             ->setRpp(100);
  586.         $variants_pattern = array();
  587.         for ($i 1$i <= 99$i++) {
  588.             foreach (array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') as $letter) {
  589.                 $k strtolower(
  590.                     sprintf('%d%s',$i,$letter)
  591.                 );
  592.                 $variants_pattern[$k] = null;
  593.             }
  594.         }
  595.         $data['variants'] = [];
  596.         $temp = [];
  597.         foreach ($search->getResult()['data'] as $product) {
  598.             if($product->getIsDeleted() == false && $product->getIsHidden() == false) {
  599.                 $variant $this->eshopProductsHandle->getProductReturnArrayBlock($product$lang, []);
  600.                 //$variant['detail_url'] = $this->getHolderUrl($product->getHolder(), $lang).'/'.$product->getCode();
  601.                 //$variant['detail_url'] = $this->eshopProductsHandle->getProductUrl();
  602.                 if($active_product) {
  603.                     if($active_product->getId() == $product->getId()) {
  604.                         $variant['is_selected'] = true;
  605.                     }
  606.                 }
  607.                 if(array_key_exists(strtolower($variant['name']), $variants_pattern)) {
  608.                     $variants_pattern[strtolower($variant['name'])] = $variant;
  609.                 } else {
  610.                     $temp[] = $variant;
  611.                 }
  612.             }
  613.         }
  614.         $data['variants'] = array_values(
  615.             array_filter($variants_pattern)
  616.         );
  617.         //append rest
  618.         foreach ($temp as $temp_variant) {
  619.             $data['variants'][] = $temp_variant;
  620.         }
  621.         $data['recommended'] = $this->eshopProductsHandle->getRecommended($holder);
  622.         $data['producer_products'] = ($holder->getProducer()) ? $this->eshopProducersHandle->getProducerProducts([$holder->getProducer()->getId()])['filtered'] : [];
  623.         return $data;
  624.     }
  625.     private function getHolderUrl(Product $holder$lang) {
  626.         $dev_prefix '';
  627.         $url '/'.$lang.'/';
  628.         if($this->controller->get'kernel' )->getEnvironment() == 'dev')
  629.             $dev_prefix '/app_dev.php';
  630.         /*
  631. $category = null;
  632. foreach($this->controller->get('eshop_categories_handle')->getProductCategories($product) as $product_category) {
  633.     if($product_category->getCategory()->getParentRow()) {
  634.         $category = $product_category->getCategory();
  635.         break;
  636.     }
  637. }
  638. if($category)
  639. {
  640.     if($category->getParentRow())
  641.     {
  642.         if($category->getParentRow()->getParentRow())
  643.         {
  644.             if($category->getParentRow()->getParentRow()->getParentRow())
  645.             {
  646.                 $url .= $category->getParentRow()->getParentRow()->getParentRow()->getName().'/';
  647.             }
  648.             $url .= $category->getParentRow()->getParentRow()->getName().'/';
  649.         }
  650.         $url .= $category->getParentRow()->getName().'/';
  651.     }
  652.     $url .= $category->getName().'/';
  653.     $url .= str_replace(array('  '),' ',$this->getProductName($product, $lang)).'/';
  654.     $url .= $product->getId();
  655. }
  656. else
  657. {
  658.     $url .= 'produkt/'; //$category->GetName().'/';//'drevene-podlahy/';//$category->getName().'/';
  659.     $url .= str_replace(array('  '),' ',$this->getProductName($product, $lang)).'/';
  660.     $url .= $product->getId();
  661. }
  662. */
  663.         $url .= 'produkt/';
  664.         $product $this->em->getRepository('Kiwi\EshopBundle\Entity\Product')->findOneBy(array(
  665.             'holder_id' => $holder->getId()
  666.         ));
  667.         if($product) {
  668.             foreach($this->eshopCategoriesHandle->getProductCategoriesNoCache($product) as $product_category) {
  669.                 if($product_category->getCategory()) {
  670.                     $url .= $product_category->getCategory()->getSeoName()."/";
  671.                 }
  672.             }
  673.         }
  674.         $url .= $this->languages->getLangEntry($holder->getArticle()->getName(), $lang).'/';
  675.         $url .= $holder->getTransportCode();
  676.         $url $dev_prefix.$this->pageExtensions->webalizeFunction($url);
  677.         return $url;
  678.     }
  679. }