Hello, this question is not answered anywhere so here it is.
It will be very nice to have products on category page with subcategories , from those subcategories which the parrent category holds.
By the way I managed to have that done but with many bugs (for now).
In default_filter just after // We show them all
my code looks like this:
PHP Code:
{
$categories = $db->Execute("SELECT c.categories_id,c.parent_id
FROM " . TABLE_CATEGORIES . " c
WHERE c.parent_id = " . (int)$current_category_id . "
);
$LCatID = '';
foreach ($categories as $category) {
$categories_count++;
$rows++;
$LCatID .= $category['categories_id'].',';
}
if ($LCatID ==! null ){$mCatID = rtrim($LCatID, ',');}else { $mCatID =(int)$current_category_id;}
// We show them all
$listing_sql = "SELECT DISTINCT " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id,s.expires_date as expires_date, s.status as status,
p.manufacturers_id, 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,
p.products_qty_box_status";
$listing_sql .= " FROM " . TABLE_PRODUCTS . " p" .
" LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id" .
" LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id" .
" LEFT JOIN " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id" .
" JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id" .
($filter_attr == true ? " JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " p2a on p.products_id = p2a.products_id" .
" JOIN " . TABLE_PRODUCTS_OPTIONS . " po on p2a.options_id = po.products_options_id" .
" JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on p2a.options_values_id = pov.products_options_values_id" .
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as on p.products_id = p2as.products_id " : "") : '');
$listing_sql .= " WHERE p2c.categories_id in (" . $mCatID . ")
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1" .
$filter .
$alpha_sort.
" GROUP BY p.products_id " .
$having;
}
there $mCatID as you see returns list of all children categories wich the parent hods, and i just add this list when the category is parrent instead of $current_category_id = p2c.categories_id as there is no p2c.categories_id on parent categorries.
And this wok for the part that there is list of all products with links to them exept that it returns those results without images, without product_name and so on. And the link of the product have some wierd parameters like:
www.website.com/product_url?1701_4
1701_4 is probably my category and its subcategory, but the funiset thing is that the link is working fine.
I supose there is a lot more to edit to make this work like I need it. But hey there must be some easy fix that I can't think of, so if somebody can help me with that I will be very happy as well some others like me having the same wish come true.
Kind regards and many thanks to everybody.
Bookmarks