language->id; $category_id = Tools::getValue('category'); if (!$id_lang) { $id_lang = $this->context->language->id; } $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q'))); $output = array(); $search_results = $jxsearchclass->jxfind((int)$id_lang, $query, $category_id, 1, 1000, 'position', 'desc', true); if (is_array($search_results)) { $imageRetriever = new ImageRetriever($this->context->link); foreach ($search_results as &$product) { $usetax = (Product::getTaxCalculationMethod((int)Context::getContext()->customer->id) != PS_TAX_EXC); $product = (new ProductAssembler($this->context)) ->assembleProduct(array('id_product' => $product['id_product'])); $presenterFactory = new ProductPresenterFactory($this->context); $presentationSettings = $presenterFactory->getPresentationSettings(); $presenter = new ProductListingPresenter( new ImageRetriever( $this->context->link ), $this->context->link, new PriceFormatter(), new ProductColorsRetriever(), $this->context->getTranslator() ); $result = $presenter->present( $presentationSettings, $product, $this->context->language ); $result['manufacturer_name'] = Manufacturer::getNameById($result['id_manufacturer']); $result['supplier_name'] = Supplier::getNameById($result['id_supplier']); $this->context->smarty->assign( 'jxsearchsettings', array( 'jxsearch_image' => (bool)Configuration::get('PS_JXSEARCH_AJAX_IMAGE'), 'jxsearch_description' => (bool)Configuration::get('PS_JXSEARCH_AJAX_DESCRIPTION'), 'jxsearch_price' => (bool)Configuration::get('PS_JXSEARCH_AJAX_PRICE'), 'jxsearch_reference' => (bool)Configuration::get('PS_JXSEARCH_AJAX_REFERENCE'), 'jxsearch_manufacturer' => (bool)Configuration::get('PS_JXSEARCH_AJAX_MANUFACTURER'), 'display_supplier' => (bool)Configuration::get('PS_JXSEARCH_AJAX_SUPPLIERS') ) ); $this->context->smarty->assign('usetax', $usetax); $this->context->smarty->assign('product', $result); // verify if the method for no image exists. Was added in 1.7.4.0 if (method_exists($imageRetriever, 'getNoPictureImage')) { $this->context->smarty->assign('search_no_image', $imageRetriever->getNoPictureImage($this->context->language)); } else { $this->context->smarty->assign('search_no_image', false); } $output[] = $jxsearch->display($jxsearch->getLocalPath(), '/views/templates/hook/_items/row.tpl'); } } if (!count($output)) { $l = new Jxsearch(); $this->ajaxDie(json_encode(array('empty' => $l->l('No product found')))); } $total = count($output); $this->ajaxDie(json_encode(array('result' => $output, 'total' => $total))); parent::initContent(); } }