Post by Pat073 » Wed Mar 26, 2025 12:06 am

Version 3.0.4.0
Would like to display the filter_id from oc_product_filter table above product image on the category page.
It is on a development site where I need a way to scroll quickly the products and check my product filters. No need pull data from oc_filter... table, only have 1 group and 5 filters, so just the id would definitely help.
Thanks

Newbie

Posts

Joined
Wed Feb 21, 2024 3:55 am

Post by halfhope » Mon Jun 16, 2025 12:05 pm

Hi!

If you want to do it manually, you may look how someone made similar moment to show product attributes. But you should replace attribute models to filter models. Also needle functions (SQL code to request product's filter_id) may not exists(idk), so you should create it.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by paulfeakins » Mon Jun 16, 2025 6:02 pm

Pat073 wrote:
Wed Mar 26, 2025 12:06 am
Would like to display the filter_id from oc_product_filter table above product image on the category page.
Sounds like you might be doing something inadvisable. Give us a bit more info about what you're trying to do and why?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by gogoweb » Sat Jun 28, 2025 5:09 am

I wrote a quick function for you to place in the model/catalog/product (ModelCatalogProduct)
and call that from your category controller or where you want.
This will give you the ids and names of filters.
Simply pass the result to your view and you see the filter_id-filter_name,otherfilter_id-othername etc.

Code: Select all

	
	// accepts (int) product_id
	// returns filters as one string
	
	public function getProductFilters($product_id) {
		$sql = "SELECT p.product_id, GROUP_CONCAT(pf.filter_id,'-',fd.name) AS filters FROM `" . DB_PREFIX . "product` p
LEFT JOIN `" . DB_PREFIX . "product_filter` pf ON  p.product_id = pf.product_id 
LEFT JOIN `" . DB_PREFIX . "filter_description` fd ON  pf.filter_id = fd.filter_id
WHERE p.product_id = ".(int)$product_id."
GROUP BY p.product_id
";

		$query = $this->db->query($sql);
		return $query->row['filters'];
		
	}	
	

All mods | OpenCart Bulk Related Products Ultimate Edition |GeoIP hide Prices / no add to cart by country| CSS override | Direct link to checkout / skip add to cart / buy now link | AUTO pilot - reward & purchase points


New member

Posts

Joined
Sat Oct 18, 2014 6:45 pm

Who is online

Users browsing this forum: Bing [Bot] and 33 guests