The music genre filter shows sql joins for product_extra tables. It should be in the same folder as your default_filter.php file. If not, here's a sample (it has several other tables joined in, which you can delete if you only need one joined table):
Code:
$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = 1, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping
from " . TABLE_PRODUCTS . " p, " .
TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_MUSIC_GENRE . " m
where m.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
and p.products_id = pme.products_id
and p.products_status = 1
and pme.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
and pme.products_id = p2c.products_id
and pd.products_id = p2c.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
If deleting some joins, be careful with your string closures and concatenations.
Here it is with just the one extra table joined:
Code:
$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = 1, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, pme.[your extra field here]
from " . TABLE_PRODUCTS . " p, " .
TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c
where p.products_id = pme.products_id
and p.products_status = 1
and pme.products_id = p2c.products_id
and pd.products_id = p2c.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
(untested)
But I think there's a lot more to it than just getting the table joined and adding a field or 3 to the query. Such as getting the info into the product listing display, sorting, etc.
Bookmarks