Shawdow's avatar

How to fetch the data for multiple checkbox like ecommerce filter panel.

Hi,

https://screenshots.firefox.com/R8tEQqtjFrokBc77/www.flipkart.com

above filter panel displays the internal storage with different memory.does any have an idea how to fetch those values from the database and display it.

Thanks,

0 likes
6 replies
biishmar's avatar

@Shawdow These things are called features, you have to assign it to category, so u can get which feature displays on which category page.. These feature belongs to product also, so u have to assign this feature to products... When u display the feature in filet panel u can display how many product near it..

Shawdow's avatar

@biishmar that's okay but how to divide those value example if i have 4-64gb memory in the database.

how to show the view like

4-8gb 8-32gb 32-64gb

any idea sir??

biishmar's avatar

@Shawdow

Category->hasMany->feature->hasMany->values.. if you make a eloquent relationship like this..

blade

@foreach($category->feature as $feature) {
    <h3> $feature->name </h3>
    <ul> 
    @foreach($feature->values as $values) {
        <li> $value->name </li>
    }
        </ul>
}

This will display all filters that related with category with values, those values are 4-8gb 8-32gb 32-64gb and feature is internal storage....

Shawdow's avatar

@biishmar okay sir i will add the relationship and fetch those data from the database.but the logic does not holds good i think i need to take some average of it and display.suppose if i have screen size and all those data cannot be fetched from the database and display it. https://screenshots.firefox.com/iBmLWq8cm1EbgxD3/www.flipkart.com

your solution is displaying the indivigual values.not like taking the average(i don't know) and display it :)

biishmar's avatar

@Shawdow Those are not taking average from feature values, they created a feature value like that..

For example: if i have category feature like screen size in that screenshot instead of 1, 2, 3, 4, 5 inches i would create like less than 3, 4 - 5 inches, 5 - 6 inches, if i have screen size 4.5 it should come btw 4-5 inches...

you got it now?

Shawdow's avatar

@biishmar yeah i got it now sir something like doing hard code in UI write the back end code to work based on the selected check boxes.i may right now!!

Please or to participate in this conversation.