I'm trying to work out if there is a way to integrate location based filtering into Magento catalog & search pages.
To place the above in context my use case is as follows: Products have latitude and longitude attributes as they are located around the country. What I want customers to be able to do is filter the products by location relative to their own location.
I've managed to successfully implement a custom search page to achieve the location search however it lacks all the other filter/search capabilities found in Magento. The ideal scenario is for the location to be a dynamically calculated variable however I'm unsure how to go about this, or if it's even viable in Magento.
Thanks in advance for any suggestions!
For starters, you can try something like this:
distance_from_customer
, default value 0, filterable in layered navigationcatalog_product_collection_load_after
, which will change each product's distance_from_customer
attribute in the loaded collection based on customer's location each time you load a product collection ( in category view for example )distance_from_customer
if there is only one default value ( 0 )In this solution distance_from_customer
will always be 0 in the database, only will be changed in the product collection object before showing on frontend and the sorting / filtering option will be hidden if the application failed to get customer location data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With