OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums OroCommerce How to change number of items shown in quick form's autocomplete

This topic contains 10 replies, has 3 voices, and was last updated by Ilya Antypenko Ilya Antypenko 5 months ago.

  • Creator
    Topic
  • #39015

    Mauro Chojrin
    Participant

    Hi:

    My client is testing out the website and he reported that there are missing items when choosing from the quick form’s autocomplete.

    The thing is, I took a look at the ajax call and saw the request looks like this:

    Is there a way to change the per_page parameter? I’d like to get every possible result…

    As a matter of fact, I’m always getting 7 results back (Though I know there are more products matching the query criteria).

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • #39022
    Ilya Antypenko
    Ilya Antypenko
    Participant

    Hi Mauro

    Could you please check in a browser network tab number of returned results for your request?
    We need to verify that server returns all 10 results.

    #39026

    Mauro Chojrin
    Participant

    Sure. This is the result I get:

    From a request like: /autocomplete/search?name=oro_product_visibility_limited&per_page=10&query=hamburguesa

    As you can see, I’m not getting 10 results but 7 (Even though there are more than 10 products matching that criteria in my db).

    I also noticed some products are marked as upcoming (though they shoudln’t… I don’t know why that is). I thought they were being left out of the query but apparently that’s not the case…

    #39044
    Ilya Antypenko
    Ilya Antypenko
    Participant

    According to response from the server it means that only this 7 products are match criteria.

    Could you please check that you can find missed products with product grid and you can open view page of this products?

    You can also debug logic to understand why products are skipped.

    Next code is used to get results:
    https://github.com/oroinc/orocommerce/blob/e3fd1dbfd160b3b4eb0d84415b08872dfc473fff/src/Oro/Bundle/ProductBundle/Autocomplete/ProductVisibilityLimitedSearchHandler.php#L175-L188

    Also some restrictions can be applied to search request (for example visibility restriction, only enabled products, etc).

    https://github.com/oroinc/orocommerce/blob/e3fd1dbfd160b3b4eb0d84415b08872dfc473fff/src/Oro/Bundle/ProductBundle/EventListener/ProductVisibilityRestrictionListener.php#L49

    #39053

    Mauro Chojrin
    Participant

    Hi Ilya:

    Thanks for your help! I just run a test and found this:

    In response to a request like /autocomplete/search?name=oro_product_visibility_limited&per_page=10&query=medallon

    On the main catalogue view I can find several more products which I can find using different search terms and I can access through the view page

    #39054
    Ilya Antypenko
    Ilya Antypenko
    Participant

    Could you please confirm that your issue is resolved?

    #39056

    Mauro Chojrin
    Participant

    It’s not resolved yet…

    #39058
    Ilya Antypenko
    Ilya Antypenko
    Participant

    You need to check all restriction which are applied to this query.
    You can find all listeners by event name: oro_product.product_search_query.restriction

    According to your information some products are filtered.

    Product must be:
    – enabled
    – inventory status from configuration must be allowed (Visible Inventory Statuses), https://oroinc.com/b2b-ecommerce/doc/current/user-guide/inventory
    – variant/configurable according to configuration settings

    #39061
    Michael
    Michael
    Keymaster

    On the main catalogue view I can find several more products which I can find using different search terms and I can access through the view page

    This is expected, as the main search and the autocomplete use different fields when searching:

    Autocomplete searches only through product name and SKU fields – https://github.com/oroinc/orocommerce/blob/3.1.8/src/Oro/Bundle/ProductBundle/Entity/Repository/ProductRepository.php#L132-L133

    The main search in addition to that considers all other searchable product attributes – https://github.com/oroinc/orocommerce/blob/3.1.8/src/Oro/Bundle/ProductBundle/Resources/config/oro/datagrids.yml#L779

    #39101

    Mauro Chojrin
    Participant

    I see. Well, the problem is some results can be found in the quick form using slightly different search terms, so the problem doesn’t seem to be about the products themselves but the search…

    What I noticed in the code is that there is a parameter that governs this, namely $maxResults.

    I believe if I could simply change the value of this parameter I should be fine… is there some config file I should look at?

    Thanks

    #39108
    Ilya Antypenko
    Ilya Antypenko
    Participant

    > I believe if I could simply change the value of this parameter I should be fine… is there some config file I should look at?

    Parameter per_page is used for pagination.
    If you get less than per_page items and more=false it means no more results in the search and you need to check why products are not showed.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No