Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function indexAction(LayoutBoxSettingsCollection $boxSettings)
 {
     $dataset = $this->get('search.dataset.front');
     $conditions = new ConditionsCollection();
     $requestHelper = $this->getRequestHelper();
     $limit = $this->manager->getRequestHelper()->getAttributesBagParam('limit', $boxSettings->getParam('per_page', 12));
     $conditions = $this->manager->addSearchConditions($conditions);
     $conditions = $this->get('layered_navigation.helper')->addLayeredNavigationConditions($conditions);
     $products = $dataset->getResult('array', ['limit' => $limit, 'page' => $requestHelper->getAttributesBagParam('page', 1), 'order_by' => $requestHelper->getAttributesBagParam('orderBy', 'score'), 'order_dir' => $requestHelper->getAttributesBagParam('orderDir', 'asc'), 'conditions' => $conditions]);
     return $this->displayTemplate('index', ['dataset' => $products]);
 }
Ejemplo n.º 2
0
 public function viewAction()
 {
     $requestHelper = $this->getRequestHelper();
     $phrase = $requestHelper->getAttributesBagParam('phrase');
     if (strlen($phrase) < $this->container->getParameter('search_term_min_length')) {
         $liveSearchContent = '';
     } else {
         $dataset = $this->get('search.dataset.front');
         $conditions = new ConditionsCollection();
         $conditions = $this->manager->addSearchConditions($conditions);
         $conditions = $this->get('layered_navigation.helper')->addLayeredNavigationConditions($conditions);
         $products = $dataset->getResult('array', ['limit' => 20, 'page' => 1, 'order_by' => 'score', 'order_dir' => 'asc', 'conditions' => $conditions]);
         $liveSearchContent = $this->renderView('WellCommerceSearchBundle:Front/Search:view.html.twig', ['dataset' => $products]);
     }
     return $this->jsonResponse(['liveSearchContent' => $liveSearchContent]);
 }