Page 1 of 1
Access products_ids of product_listing
Posted: Tue Aug 09, 2022 6:13 pm
by Kofod95
Is there a way to get the product_id's in the current listing, no matter the page?
I ask because I would like to experiment with product-filters available on all listings, and think this might help.
//Daniel
Re: Access products_ids of product_listing
Posted: Tue Aug 09, 2022 7:19 pm
by ecartz
If you are filtering, wouldn't you want to do it before the IDs are generated? The obvious solution for that would be to modify the
listing_sql in listen_filterStart.
You could build a list of IDs from the product_card template (start recording at filterStart and stop at drawForm), but that would give you a list after the products are displayed. The listing_sql would allow you to change the list.
Re: Access products_ids of product_listing
Posted: Tue Aug 09, 2022 7:30 pm
by Kofod95
Thank you for the reply!
I will use filter_start for the filtering-action, but would like to only show the filters that would actually return any products. Previously, I did that by finding the available option_value_id's in $current_category, but that obviously only works in a category and not on a manufacturers page, specials.php or advanced_search_results.
ecartz wrote: ↑Tue Aug 09, 2022 7:19 pm
You could build a list of IDs from the product_card template (start recording at filterStart and stop at drawForm)
Thank you! I'll try working with this!
//Daniel
Re: Access products_ids of product_listing
Posted: Tue Aug 09, 2022 8:23 pm
by ecartz
I don't think that approach would work. It would show the IDs in the current search results. But you also want to know the results that do not show on that page. You need something like
Code: Select all
SELECT DISTINCT(p.manufacturers_id) FROM products p
with the appropriate joins and where clauses. Probably as a subselect since you also would want the manufacturers' name. You can't build what you want in PHP alone. The data is in the database and you'll need to go get it.