Esempio n. 1
0
 public function _autocomplete($search_category_id, $search_name, $params)
 {
     VmConfig::loadJLang('com_virtuemart', true);
     VmConfig::loadConfig();
     $list = array();
     $limitation = (int) $params->get('limit', 8);
     $source_group = null;
     $catids = $search_category_id == 0 ? 0 : $search_category_id;
     $query = ' * , pp.product_price FROM `#__virtuemart_products_en_gb` p LEFT JOIN #__virtuemart_product_prices pp ON p.virtuemart_product_id = pp.virtuemart_product_id';
     if ($search_category_id != 0) {
         $query .= " LEFT JOIN `#__virtuemart_product_categories` pc ON (p.virtuemart_product_id = pc.virtuemart_product_id) WHERE pc.virtuemart_category_id = " . $search_category_id . " AND p.product_name LIKE '%" . $search_name . "%'";
     } else {
         $query .= " WHERE p.product_name LIKE '%" . $search_name . "%'";
     }
     //$source_group = null;
     $productModel = VmModel::getModel('Product');
     //$productModel = new VirtuemartModelProductExtend();
     $items = $productModel->exeSortSearchListQuery(0, $query, '', '', '', '', '', $limitation);
     if ($limitation == 0) {
         $productModel->_noLimit = true;
     } else {
         $productModel->_noLimit = false;
     }
     //$productModel->addImages($items,1);
     $ratingModel = VmModel::getModel('ratings');
     $small_image_config = array('type' => $params->get('imgcfg_type'), 'width' => $params->get('imgcfg_width'), 'height' => $params->get('imgcfg_height'), 'quality' => 90, 'function' => $params->get('imgcfg_function') == 'none' ? null : 'resize', 'function_mode' => $params->get('imgcfg_function') == 'none' ? null : substr($params->get('imgcfg_function'), 7), 'transparency' => $params->get('imgcfg_transparency', 1) ? true : false, 'background' => $params->get('imgcfg_background'));
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     foreach ($items as $item) {
         $virtuemart_product_id = $item->virtuemart_product_id;
         $quantity = 1;
         $product_info = $productModel->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
         $productModel->addImages($product_info);
         $item_img = VmSearchProHelper::getVmImage($product_info, $params);
         $image = VmSearchProHelper::imageTag($item_img, $small_image_config);
         $salesPrice = "";
         $discountAmount = "";
         if (!empty($product_info->prices['salesPrice'])) {
             $salesPrice = $currency->createPriceDiv('salesPrice', JText::_("SALES_PRICE"), $product_info->prices, false, false, 1.0);
         }
         if (!empty($product_info->prices['discountAmount'])) {
             $discountAmount = $currency->createPriceDiv('discountAmount', JText::_("DISCOUNT_AMOUNT"), $product_info->prices, false, false, 1.0);
         }
         $list[] = array('name' => $item->product_name, 'product_id' => $item->virtuemart_product_id, 'salesPrice' => $salesPrice, 'discountAmount' => $discountAmount, 'image' => $image, 'link' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $product_info->virtuemart_category_id . '&virtuemart_product_id=' . $product_info->virtuemart_product_id . '&keyword=' . $search_name . ''), 'category_name' => $product_info->category_name);
     }
     die(json_encode($list));
 }
<?php

/**
 * @package SJ Search Pro for VirtueMart
 * @version 3.0.1
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2015 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */
defined('_JEXEC') or die;
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
require_once dirname(__FILE__) . '/core/helper.php';
$layout = $params->get('layout', 'default');
$Search_helper = new VmSearchProHelper($params, $module);
$is_ajax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
$is_ajax_searchpro = (int) JRequest::getVar('is_ajax_searchpro', 0);
if ($is_ajax && $is_ajax_searchpro) {
    $search_module_id = (int) JRequest::getVar('search_module_id');
    if ($search_module_id == $module->id) {
        $search_category_id = JRequest::getVar('search_category_id');
        $search_name = JRequest::getVar('search_name');
        $Search_helper->_autocomplete($search_category_id, $search_name, $params);
        $category_id = vRequest::getInt('virtuemart_category_id', 0);
        $search_name = vRequest::getVar('keyword', '');
    }
}
if ($params->get('show_form_category')) {
    $categories = array();
    $category_id = 0;
    /* Level 1 */