Example #1
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_order_status']) && Validate::isInt($filter['id_order_status'])) {
            $where .= ' AND a.`id_order_status`=' . intval($filter['id_order_status']);
        }
        if (!empty($filter['color']) && Validate::isCatalogName($filter['color'])) {
            $where .= ' AND a.`color` LIKE "%' . pSQL($filter['color']) . '%"';
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['send_mail']) && Validate::isInt($filter['send_mail'])) {
            $where .= ' AND a.`send_mail`=' . ((int) $filter['send_mail'] == 1 ? '1' : '0');
        }
        if (!empty($filter['email_tpl']) && Validate::isInt($filter['email_tpl'])) {
            $where .= ' AND a.`email_tpl` LIKE "%' . pSQL($filter['email_tpl']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_order_status` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'order_status` a
				WHERE 1 ' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'order_status` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #2
0
    public static function loadData($p = 1, $limit = 1000, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (isset($filter['id_feature_value']) && Validate::isInt($filter['id_feature_value'])) {
            $where .= ' AND a.`id_feature_value`=' . intval($filter['id_feature_value']);
        }
        if (isset($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (isset($filter['id_feature']) && Validate::isInt($filter['id_feature'])) {
            $where .= ' AND a.`id_feature`=' . intval($filter['id_feature']);
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `position` ASC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'feature_value` a
				WHERE 1 ' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'feature_value` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #3
0
    public static function getRule($active = true, $p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $where = '';
        if (!empty($filter['id_rule']) && Validate::isInt($filter['id_rule'])) {
            $where .= ' AND a.`id_rule`=' . intval($filter['id_rule']);
        }
        if (!empty($filter['entity']) && Validate::isCatalogName($filter['entity'])) {
            $where .= ' AND a.`entity` LIKE "%' . pSQL($filter['entity']) . '%"';
        }
        if (!empty($filter['rule_link']) && Validate::isCatalogName($filter['rule_link'])) {
            $where .= ' AND a.`rule_link` LIKE "%' . pSQL($filter['rule_link']) . '%"';
        }
        if (!empty($filter['id_entity']) && Validate::isInt($filter['id_entity'])) {
            $where .= ' AND a.`id_entity`=' . (int) $filter['id_entity'];
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `position` ASC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where);
        $result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'rules' => $result);
        return $rows;
    }
Example #4
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_order']) && Validate::isInt($filter['id_order'])) {
            $where .= ' AND a.`id_order`=' . intval($filter['id_order']);
        }
        if (!empty($filter['reference']) && Validate::isInt($filter['reference'])) {
            $where .= ' AND a.`reference`=' . intval($filter['reference']);
        }
        if (!empty($filter['payment'])) {
            $where .= ' AND a.`payment` LIKE "%' . pSQL($filter['payment']) . '%"';
        }
        if (!empty($filter['id_cart']) && Validate::isCatalogName($filter['id_cart'])) {
            $where .= ' AND a.`id_cart` = ' . intval($filter['id_cart']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND u.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['email']) && Validate::isInt($filter['email'])) {
            $where .= ' AND a.`email` LIKE "%' . pSQL($filter['email']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_order` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'order` a
				LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
				LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
				LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.*, m.name AS `payment`, u.name, c.name as carrier, os.name as status, os.color
				FROM `' . DB_PREFIX . 'order` a
				LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
				LEFT JOIN `' . DB_PREFIX . 'module` m ON (a.id_module = m.id_module)
				LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
				LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
				WHERE 1 
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #5
0
 /**
  * Search a specific string in the products and categories
  *
  * @params string $query String to find in the catalog
  */
 public function searchCatalog($query)
 {
     global $cookie;
     $products = false;
     if (Validate::isCatalogName($query)) {
         $this->_list['products'] = Product::searchByName(intval($cookie->id_lang), $query);
         if (!empty($this->_list['products'])) {
             for ($i = 0; $i < count($this->_list['products']); $i++) {
                 $this->_list['products'][$i]['nameh'] = str_ireplace($query, '<span class="highlight">' . $query . '</span>', $this->_list['products'][$i]['name']);
             }
         }
     }
     if (Validate::isCatalogName($query)) {
         $this->_list['categories'] = Category::searchByName(intval($cookie->id_lang), $query);
     }
 }
Example #6
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (isset($filter['id_address'])) {
            $where .= ' AND a.`id_address`=' . intval($filter['id_address']);
        }
        if (isset($filter['id_country'])) {
            $where .= ' AND a.`id_country`=' . intval($filter['id_country']);
        }
        if (isset($filter['id_state'])) {
            $where .= ' AND a.`id_state`=' . intval($filter['id_state']);
        }
        if (isset($filter['address']) && Validate::isCatalogName($filter['address'])) {
            $where .= ' AND a.`address` LIKE "%' . pSQL($filter['address']) . '%"';
        }
        if (isset($filter['city']) && Validate::isCatalogName($filter['city'])) {
            $where .= ' AND a.`city` LIKE "%' . pSQL($filter['city']) . '%"';
        }
        if (isset($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_address` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'address` a
				LEFT JOIN  `' . DB_PREFIX . 'country` c ON (a.id_country = c.id_country)
				LEFT JOIN  `' . DB_PREFIX . 'state` s ON (a.id_state = s.id_state)
				WHERE 1' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.*, c.name AS country, s.name AS state FROM `' . DB_PREFIX . 'address` a
				LEFT JOIN  `' . DB_PREFIX . 'country` c ON (a.id_country = c.id_country)
				LEFT JOIN  `' . DB_PREFIX . 'state` s ON (a.id_state = s.id_state)
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #7
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_cms']) && Validate::isInt($filter['id_cms'])) {
            $where .= ' AND a.`id_cms`=' . intval($filter['id_cms']);
        }
        if (!empty($filter['title']) && Validate::isCatalogName($filter['title'])) {
            $where .= ' AND a.`title` LIKE "%' . pSQL($filter['title']) . '%"';
        }
        if (!empty($filter['rewrite']) && Validate::isCatalogName($filter['rewrite'])) {
            $where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!empty($filter['is_top']) && Validate::isInt($filter['is_top'])) {
            $where .= ' AND a.`is_top`=' . ((int) $filter['is_top'] == 1 ? '1' : '0');
        }
        if (!empty($filter['id_cms_category']) && Validate::isInt($filter['id_cms_category']) && $filter['id_cms_category'] > 1) {
            $where .= ' AND a.`id_cms` IN (SELECT `id_cms` FROM `' . DB_PREFIX . 'cms_to_category` WHERE `id_cms_category`=' . intval($filter['id_cms_category']) . ')';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_cms` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'cms` a
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'cms` a
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => self::resetCMS($result));
        return $rows;
    }
Example #8
0
    /**
     * 获取数据
     * @param int $p
     * @param int $limit
     * @param null $orderBy
     * @param null $orderWay
     * @param array $filter
     * @return array|bool
     */
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_state']) && Validate::isInt($filter['id_state'])) {
            $where .= ' AND a.`id_state`=' . intval($filter['id_state']);
        }
        if (!empty($filter['iso_code']) && Validate::isCatalogName($filter['iso_code'])) {
            $where .= ' AND a.`iso_code`="' . pSQL($filter['subject']) . '"';
        }
        if (!empty($filter['id_country']) && Validate::isCatalogName($filter['id_country'])) {
            $where .= ' AND a.`id_country` = ' . intval($filter['id_country']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_state` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'state` a
				LEFT JOIN `' . DB_PREFIX . 'country` c ON (a.id_country = c.id_country)
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.*, c.name as country FROM `' . DB_PREFIX . 'state` a
				LEFT JOIN `' . DB_PREFIX . 'country` c ON (a.id_country = c.id_country)
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #9
0
    public static function loadData($p = 1, $limit = 1000, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_carrier']) && Validate::isInt($filter['id_carrier'])) {
            $where .= ' AND a.`id_carrier`=' . intval($filter['id_carrier']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!empty($filter['shipping']) && Validate::isPrice($filter['shipping'])) {
            $where .= ' AND a.`shipping`=' . $filter['shipping'];
        }
        if (!empty($filter['description']) && Validate::isInt($filter['description'])) {
            $where .= ' AND a.`description` LIKE "%' . pSQL($filter['description']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_carrier` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'carrier` a
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'carrier` a
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => self::reLoad($result));
        return $rows;
    }
    /**
     * Light back office search for categories
     *
     * @param integer $id_lang Language ID
     * @param string $query Searched string
     * @param boolean $unrestricted allows search without lang and includes first category and exact match
     * @return array Corresponding categories
     */
    public static function searchByName($id_lang, $query, $unrestricted = false)
    {
        if (!Validate::isCatalogName($query)) {
            die(Tools::displayError());
        }
        if ($unrestricted === true) {
            return Db::getInstance()->getRow('
			SELECT c.*, cl.*
			FROM `' . _DB_PREFIX_ . 'category` c
			LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`)
			WHERE `name` LIKE \'' . pSQL($query) . '\'');
        } else {
            return Db::getInstance()->ExecuteS('
			SELECT c.*, cl.*
			FROM `' . _DB_PREFIX_ . 'category` c
			LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . intval($id_lang) . ')
			WHERE `name` LIKE \'%' . pSQL($query) . '%\' AND c.`id_category` != 1');
        }
    }
Example #11
0
    /**
     * Return current category childs
     *
     * @param integer $id_lang Language ID
     * @param boolean $active return only active categories
     * @return array Categories
     */
    public function getSubCMSCategories($limit = 20, $p = 20, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_cms_category']) && Validate::isInt($filter['id_cms_category'])) {
            $where .= ' AND `id_cms_category`=' . intval($filter['id_cms_category']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND `name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['rewrite']) && Validate::isCatalogName($filter['rewrite'])) {
            $where .= ' AND `rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND `active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `position` ASC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'cms_category`
		WHERE `id_cms_category` != 1
		' . $where);
        $result = Db::getInstance()->getAll('
		SELECT * FROM `' . DB_PREFIX . 'cms_category`
		WHERE `id_parent` = ' . (int) $this->id . ' ' . $where . '
		' . $postion . '
		LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Example #12
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (isset($filter['id_product'])) {
            $where .= ' AND a.`id_product`=' . intval($filter['id_product']);
        }
        if (isset($filter['id_brand'])) {
            $where .= ' AND a.`id_brand`=' . intval($filter['id_brand']);
        }
        if (isset($filter['brand.active'])) {
            $where .= ' AND IF(b.id_brand > 0,b.active=' . intval($filter['brand.active']) . ',1)';
        }
        if (isset($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (isset($filter['rewrite']) && Validate::isCatalogName($filter['rewrite'])) {
            $where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (isset($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (isset($filter['is_stock'])) {
            $where .= ' AND a.`is_stock`=' . ((int) $filter['is_stock'] == 1 ? '1' : '0');
        }
        if (isset($filter['is_sale'])) {
            $where .= ' AND a.`is_sale`=' . ((int) $filter['is_sale'] == 1 ? '1' : '0');
        }
        if (isset($filter['id_category']) && $filter['id_category'] > 1) {
            $where .= ' AND (a.`id_product` IN (SELECT `id_product` FROM `' . DB_PREFIX . 'product_to_category` WHERE `id_category`=' . intval($filter['id_category']) . ') OR a.id_category_default =' . intval($filter['id_category']) . ')';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_product` DESC';
        }
        $total = Db::getInstance()->getValue('SELECT count(*) AS total FROM `' . DB_PREFIX . 'product` a
				LEFT JOIN `' . DB_PREFIX . 'category` AS c ON a.id_category_default = c.id_category
				LEFT JOIN `' . DB_PREFIX . 'brand`  AS b ON a.id_brand = b.id_brand
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.*,c.name AS c_name FROM `' . DB_PREFIX . 'product` a
				LEFT JOIN `' . DB_PREFIX . 'category` AS c ON a.id_category_default = c.id_category
				LEFT JOIN `' . DB_PREFIX . 'brand`  AS b ON a.id_brand = b.id_brand
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total, 'items' => self::reLoad($result));
        return $rows;
    }
Example #13
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_cart']) && Validate::isInt($filter['id_cart'])) {
            $where .= ' AND a.`id_cart`=' . intval($filter['id_cart']);
        }
        if (!empty($filter['subject']) && Validate::isCatalogName($filter['subject'])) {
            $where .= ' AND a.`subject` LIKE "%' . pSQL($filter['subject']) . '%"';
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!empty($filter['email']) && Validate::isInt($filter['email'])) {
            $where .= ' AND a.`email` LIKE "%' . pSQL($filter['email']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_cart` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT COUNT(*) AS total
					FROM ' . DB_PREFIX . 'cart AS a
					Left JOIN ' . DB_PREFIX . 'currency AS y ON a.id_currency = y.id_currency
					Left JOIN ' . DB_PREFIX . 'carrier AS r ON a.id_carrier = r.id_carrier
					Left JOIN ' . DB_PREFIX . 'user AS u ON a.id_user = u.id_user
					WHERE 1 ' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.id_cart,a.id_user,a.id_address,a.id_carrier,a.id_currency,u.name,r.name as carrier,r.shipping,a.status,a.add_date
					FROM ' . DB_PREFIX . 'cart AS a
					Left JOIN ' . DB_PREFIX . 'currency AS y ON a.id_currency = y.id_currency
					Left JOIN ' . DB_PREFIX . 'carrier AS r ON a.id_carrier = r.id_carrier
					Left JOIN ' . DB_PREFIX . 'user AS u ON a.id_user = u.id_user
					WHERE 1 ' . $where . '
					' . $postion . '
					LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => self::reload($result));
        return $rows;
    }
Example #14
0
    /**
     * Admin panel product search
     *
     * @param integer $id_lang Language id
     * @param string $query Search query
     * @return array Matching products
     */
    public static function searchByName($id_lang, $query)
    {
        if (!Validate::isCatalogName($query)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance()->ExecuteS('
		SELECT p.`id_product`, pl.`name`, pl.`link_rewrite`, p.`weight`, p.`active`, p.`ecotax`, i.`id_image`, p.`reference`,
		il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name
		FROM `' . _DB_PREFIX_ . 'category_product` cp
		LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = cp.`id_product`
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON t.`id_tax` = p.`id_tax`
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = ' . intval($id_lang) . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
		LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`) AND i.`cover` = 1
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ')
		WHERE pl.`name` LIKE \'%' . pSQL($query) . '%\' OR p.`reference` LIKE \'%' . pSQL($query) . '%\' OR p.`supplier_reference` LIKE \'%' . pSQL($query) . '%\'
		GROUP BY `id_product`
		ORDER BY pl.`name` ASC');
        if (!$result) {
            return false;
        }
        $resultsArray = array();
        foreach ($result as $k => $row) {
            $row['price'] = Product::getPriceStatic($row['id_product'], true, NULL, 2);
            $row['quantity'] = Product::getQuantity($row['id_product']);
            $resultsArray[] = $row;
        }
        return $resultsArray;
    }