yf_shop_search user module

Fileplugins/shop/modules/shop/yf_shop_search.class.php
Usemodule('shop_search'), URL ?object=shop_search

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 3

prepare_str

public function prepare_str($string)
    public function prepare_str($string)
    {
        $patrn = "/([\[\}\]\{\%\"\'\<\>\~\!\@\#\$\%\&\*\(\)\s\-\_\\:\;\+\=\|\?\№\.\\/\^\,])+/iu";
        $patrn2 = ['<', '>'];
        $string = str_replace($patrn2, '', $string);
        $string = _strtolower(trim($string));
        $string = preg_replace($patrn, ',', $string);
        $string = trim($string, ',');
        $str_search = explode(',', $string);
        $rezult = $this->search_fast($str_search);
        return $rezult;
    }

search_fast

public function search_fast($str_search)
    public function search_fast($str_search)
    {
        $str_search2 = implode(' ', $str_search);
        $str_search = implode('%', $str_search);

        $sql = 'SELECT id FROM  ' . db('shop_products') . '  WHERE  name LIKE  ';
        $_sql = '';
        $_sql = $sql . "'%" . $str_search . "%'";
        $Q = db()->query($_sql);
        $product_ids = '';
        while ($product_id = db()->fetch_assoc($Q)) {
            $product_ids .= $product_id['id'] . ',';
        }
        $product_ids = rtrim($product_ids, ',');
        if ($product_ids == '') {
            $replace = [
                'str_search' => _prepare_html($str_search2),
                'form_action' => process_url('./?object=shop&action=search&id=fast'),
            ];
            return tpl()->parse('shop/no_search_results', $replace);
        }
        $replace = module('shop')->products_show($product_ids, $str_search2);

        return $replace;
    }