private function getProductsOrCount(ProductSearchContext $context, ProductSearchQuery $query, $type = 'products') { if ($query->getSortOrder()->isRandom()) { return $this->category->getProducts($context->getIdLang(), 1, $query->getResultsPerPage(), null, null, $type !== 'products', true, true, $query->getResultsPerPage()); } else { return $this->category->getProducts($context->getIdLang(), $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(), $query->getSortOrder()->toLegacyOrderWay(), $type !== 'products'); } }
public function runQuery(ProductSearchContext $context, ProductSearchQuery $query) { if (!($products = ProductSale::getBestSales($context->getIdLang(), $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(), $query->getSortOrder()->toLegacyOrderWay()))) { $products = array(); } $count = (int) ProductSale::getNbSales(); $result = new ProductSearchResult(); $result->setProducts($products)->setTotalProductsCount($count); $result->setAvailableSortOrders(array((new SortOrder('product', 'name', 'asc'))->setLabel($this->translator->trans('Name, A to Z', array(), 'Shop.Theme.Catalog')), (new SortOrder('product', 'name', 'desc'))->setLabel($this->translator->trans('Name, Z to A', array(), 'Shop.Theme.Catalog')), (new SortOrder('product', 'price', 'asc'))->setLabel($this->translator->trans('Price, low to high', array(), 'Shop.Theme.Catalog')), (new SortOrder('product', 'price', 'desc'))->setLabel($this->translator->trans('Price, high to low', array(), 'Shop.Theme.Catalog')))); return $result; }
public function runQuery(ProductSearchContext $context, ProductSearchQuery $query) { $products = []; $count = 0; if ($string = $query->getSearchString()) { $result = Search::find($context->getIdLang(), Tools::replaceAccentedChars(urldecode($string)), $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(), $query->getSortOrder()->toLegacyOrderWay(), false, false, null); $products = $result['result']; $count = $result['total']; } elseif ($tag = $query->getSearchTag()) { $products = Search::searchTag($context->getIdLang(), urldecode($tag), false, $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(true), $query->getSortOrder()->toLegacyOrderWay(), false, null); $count = Search::searchTag($context->getIdLang(), urldecode($tag), true, $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(true), $query->getSortOrder()->toLegacyOrderWay(), false, null); } $result = new ProductSearchResult(); $result->setProducts($products)->setTotalProductsCount($count); $result->setAvailableSortOrders($this->sortOrderFactory->getDefaultSortOrders()); return $result; }
private function getProductsOrCount(ProductSearchContext $context, ProductSearchQuery $query, $type = 'products') { return Product::getNewProducts($context->getIdLang(), $query->getPage(), $query->getResultsPerPage(), $type !== 'products', $query->getSortOrder()->toLegacyOrderBy(), $query->getSortOrder()->toLegacyOrderWay()); }
private function getProductsOrCount(ProductSearchContext $context, ProductSearchQuery $query, $type = 'products') { return $this->supplier->getProducts($this->supplier->id, $context->getIdLang(), $query->getPage(), $query->getResultsPerPage(), $query->getSortOrder()->toLegacyOrderBy(), $query->getSortOrder()->toLegacyOrderWay(), $type !== 'products'); }