public function search($query, array $data)
    {
        $sql = 'SELECT si.entity_id';

        if (!empty($data['count'])) {
            $sql = 'SELECT COUNT(si.entity_id)';
        }

        $conditions = array($query, $data['language'], 'und', 'product');

        $sql .= ' FROM search_index si
                  LEFT JOIN product p ON(p.product_id = si.entity_id)
                  WHERE MATCH(si.text) AGAINST (? IN BOOLEAN MODE)
                  AND (si.language=? OR si.language=?)
                  AND si.entity=? AND p.product_id IS NOT NULL';

        if (isset($data['status'])) {
            $sql .= ' AND p.status=?';
            $conditions[] = (int) $data['status'];
        }

        if (isset($data['store_id'])) {
            $sql .= ' AND p.store_id=?';
            $conditions[] = (int) $data['store_id'];
        }

        if (empty($data['count'])) {
            $sql .= ' GROUP BY si.entity_id';
        }

        if (!empty($data['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $data['limit']));
        }

        if (!empty($data['count'])) {
            return $this->config->getDb()->fetchColumn($sql, $conditions);
        }

        $data['product_id'] = $this->config->getDb()->fetchColumnAll($sql, $conditions);

        if (empty($data['product_id'])) {
            return array();
        }

        unset($data['language']);
        return $this->product->getList($data);
    }