Exemple #1
0
 /**
  * Retrieve search result count
  *
  * @return string
  */
 public function getResultCount()
 {
     if ($this->fallback) {
         return parent::getResultCount();
     }
     if (!$this->getData('result_count')) {
         $query = $this->_getQuery();
         $size = $this->hasSubPhrases() ? $this->p13nHelper->getSubPhraseTotalHitCount($this->queries[\Boxalino\Intelligence\Block\Product\BxListProducts::$number]) : $this->p13nHelper->getTotalHitCount();
         $this->setResultCount($size);
         $query->saveNumResults($size);
     }
     return $this->getData('result_count');
 }
 /**
  * @param $entity_ids
  */
 protected function _setupCollection($entity_ids)
 {
     $list = $this->_objectManager->create('\\Boxalino\\Intelligence\\Model\\Collection');
     $list->setStoreId($this->_storeManager->getStore()->getId())->addFieldToFilter('entity_id', $entity_ids)->addAttributeToSelect('*');
     $list->getSelect()->order(new \Zend_Db_Expr('FIELD(e.entity_id,' . implode(',', $entity_ids) . ')'));
     $list->load();
     $list->setCurBxPage($this->getToolbarBlock()->getCurrentPage());
     $limit = $this->getRequest()->getParam('product_list_limit') ? $this->getRequest()->getParam('product_list_limit') : $this->getToolbarBlock()->getDefaultPerPageValue();
     $totalHitCount = $this->p13nHelper->getTotalHitCount();
     if (ceil($totalHitCount / $limit) < $list->getCurPage() && $this->getRequest()->getParam('p')) {
         $url = $this->_url->getCurrentUrl();
         $url = preg_replace('/(\\&|\\?)p=+(\\d|\\z)/', '$1p=1', $url);
         $this->_response->setRedirect($url);
     }
     $lastPage = ceil($totalHitCount / $limit);
     $list->setLastBxPage($lastPage);
     $list->setBxTotal($totalHitCount);
     $this->_productCollection = $list;
 }