0

What is the proper way of changing what is in a search and category product colleciton? Interceptors? I've kinda tried this but it messes with the pagination of the search result.

For context. I created an extension that has its own table that holds data for year, make, and model. Each row has fields: year, make, model, product_ids (Which holds IDs of compatible products).

In the front end the user can select year make model from drop downs which is stored in their session. When the user does a search I would like to only show products that are compatible.

As a bonus I would also like for the auto complete in the search bar to take these into account as well but that's more of a bonus and not the main issue I am trying to resolve.

1 Answer 1

0

Natively, the best way to handle product attributes is with product custom attributes. They will be indexed natively and applied to filters, search criteria, etc. If you want a custom table the it will be more tricky. One option is redundancy. Every time you save a product you add such data into a custom attribute for the product. You could also extend the search classes to search for all the products with all the attributes except yours and in your plugin you could filter out those not in your table, or you could look for all the products matching your table attributes first, and then add a search filter of entity_id 'IN' all the ids you found in your query. You could also rewrite the search classes and make complex sql queries but it will be difficult and very prone to bugs.

3
  • All the current attribute types wont work very well for this. Do you know of a good document for creating a custom attribute type? Google is not giving me what I need with my search terms it seems. This makes sense though.
    – Tyler
    Commented Apr 14, 2017 at 13:40
  • What kind of attribute type are you looking for?
    – awavi
    Commented Apr 14, 2017 at 16:18
  • I could try just throwing all of the YMM data into a multi-select attribute but that still doesnt explain how I can modify a search result and filter it based on data in the current customers session.
    – Tyler
    Commented Apr 14, 2017 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.