News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Search ignores uncategorized child products

Started by sandomatyas, Yesterday at 15:44:44 PM

Previous topic - Next topic

sandomatyas

Hi,

This looks like a logic bug in frontend keyword search (sortSearchListQuery), not a misconfiguration.

Setup (intentional)

Parent product assigned to a published category
Child products have their own SKUs, are published, and are intentionally not assigned to any category (category only on the parent)
show_uncat_child_products = 1
show_unpub_cat_products = 0
Expected
Searching by the child's SKU must return the child. That is exactly what show_uncat_child_products=1 is for.

Actual
0 results. The SKU match works in SQL, but the product is dropped afterwards by the category filters.
With show_uncat_child_products=1, search correctly builds:

((p.product_parent_id = "0" AND pc.virtuemart_category_id > "0") OR p.product_parent_id > "0")
so uncategorized children are allowed.

But then show_unpub_cat_products=0 unconditionally adds:

`c`.`published` = 1
For an uncategorized child, the LEFT JOIN leaves c.published as NULL, so NULL = 1 fails and the child is excluded.

So show_unpub_cat_products=0 silently cancels show_uncat_child_products=1. That is inconsistent: one setting explicitly allows uncategorized children, the other then rejects them because they have no category row at all (not because they belong to an unpublished category).

Suggested fix
c.published = 1 should only apply when a category is actually joined, e.g.:

(`pc`.`virtuemart_category_id` IS NULL OR `c`.`published` = 1)
Assigning every child to a category is not a valid solution here — the catalog is built on purpose with categories only on parents.

Thanks.