Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit in category autocomplete #2683

Closed
hermans opened this issue Feb 17, 2015 · 5 comments
Closed

Limit in category autocomplete #2683

hermans opened this issue Feb 17, 2015 · 5 comments

Comments

@hermans
Copy link

hermans commented Feb 17, 2015

Hello,
Why in category autocomplate use limit, is this not be problem ?

admin/controller/catalog/catagory.php

public function autocomplete() {
$json = array();

    if (isset($this->request->get['filter_name'])) {
        $this->load->model('catalog/category');

        $filter_data = array(
            'filter_name' => $this->request->get['filter_name'],
            'sort'        => 'name',
            'order'       => 'ASC',
            'start'       => 0,
            'limit'       => 5   /// <<< we need to remove limit here
        );

        $results = $this->model_catalog_category->getCategories($filter_data);

        foreach ($results as $result) {
            $json[] = array(
                'category_id' => $result['category_id'],
                'name'        => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'))
            );
        }
    }

    $sort_order = array();

    foreach ($json as $key => $value) {
        $sort_order[$key] = $value['name'];
    }

    array_multisort($sort_order, SORT_ASC, $json);

    $this->response->addHeader('Content-Type: application/json');
    $this->response->setOutput(json_encode($json));
}
@danielkerr
Copy link
Member

no because some users have 1000's of categories

@bachopencart
Copy link

how to do if I have mil of Categories ? and sort_order go to million

@Rpent001
Copy link
Contributor

I imagine changing it to 10 or 15 wouldn't cause too much of an issue. Otherwise, you'd need to be very precise in your search and at that point what good is the autocomplete?

@hermans
Copy link
Author

hermans commented Apr 13, 2016

that should not use limit when load data, we can make minimum search keyword.
example: system not allow search only < 3 chars

@Rpent001
Copy link
Contributor

@hermans The limit is for 5 results. If you don't keep that reasonable, or delete it all together, it would show a list of all results as you type and go off the screen. Any site with 1000+ products will drive the admins batty showing that many results in an autocomplete. Even Google limits it to 10 I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants