Skip Navigation

[Resolved] Using relationships to perform hierarchical search.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2331871

I'm using relationships to do the following:

A
-B
--C
---D
----E

Originally the idea was to do One to Many from A to E. But then I realized there were some B's, C's, D's, etc that had multiple so I had to go the Many to Many route.

My issue is as following and maybe I can get some guidance, the idea is for this to be hierarchical, so no way of choosing a bottom category that isn't an exact match to the top one. With one to many it's pretty simple but with Many to Many I'm not sure that would still prove true?
That is one thing is that this are relationships to products basically, so I have some products that have E>D>C>B>A and some that start at C or D or even B, meaning not all have all the relationships and as of right now the custom search permits me to have

I'm not sure it would work in this way.
I was doing with Hierarchical taxonomies originally and this problem doesn't exist there since each hierarchy is unique but not here.

#2333373

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

I'll assume that you switched to post-relationships from hierarchical taxonomy, because, the hierarchical search option can only be used with the post relationships.

The challenge in this approach is that you'll have to maintain the data hierarchy at all times. If you've set the relationship search to span over 5 levels (i.e. A, B, C, D, and E), then you'll have to make sure that none of those levels is skipped for any product.

If you could share the actual names of those levels (i.e. A, B, C, D, and E), I'll be in a better position to suggest some workaround.

regards,
Waqar

#2333505

Hi Waqar,

I was hoping that wasn't the case but for now I could delete a couple and work with only 3.

Fabricantes (manufacturers)
-Modelos (models)
--Versiones (versions)
---Años (year)
----Motor (engine)

That's the structure, it's a car db in progress so some if not most prodcuts don't have Engine and some don't have 'versions'. Most all have Manufacturer and Model. Versions tend to encompass both year and engine we're trying to further sort it.
Even if I were to short it to manufacturers>models>versions, some don't have versions.

#2334153

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

To overcome this, you'll need to include a default/base/standard entry for cases, where one doesn't exist.

For example, suppose there is no specific entry needed for "version" or "engine" for a particular car listing. You can add it as:

Toyota (manufacturers)
- Corolla (models)
-- Corolla base variant (versions)
--- 2019 (year)
---- Corolla base engine (engine)

#2334417

My issue is resolved now. Thank you!

It's not optimal but it will do for now since the relationships are the optimal way to do the hierarchical search!
Thank you Waqar

#2334537

Gotta re-open because I have a related "issue".
I'm trying to mantain hierarchy but in that sense there's an issue:

Say I have:

Chevrolet
-Aveo
--09 -> Motor: 1.6

Kia
-Soul
--09 -> Motor: 1.6

In taxonomies it's fine because each one is unique but here in relationships how do I keep them being unique.
I had to go Many to Many in Versions because I had to way of telling something like the example apart.
--09 -> Motor: 1.6, maybe 10 different cars share that same year/engine format.

Right now with the many to many it doesn't really work because even though if I search for Chevrolet Aveo, the part that is for Chevrolet Aveo appears, also does the Kia - Soul one strangely enough it actually appears first.

In case you need to see exactly what I'm saying:

hidden link

#2334539

Sorry for the reply but I don't have an edit button:

At first I thought, I'll just make that 09 -> Motor: 1.6 duplicate or triplicate or whatever like with taxos and it'd be fine, but I would need to import from the Products > the Version and it should create the version right there, but that wasn't happening, if I didn't have a Version created first it would just say it didn't find the relationship post and not import anything.

#2335055

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I understand your concern and after reviewing the structure again, there is a logical solution for this.

It would make sense to use post relationships for only the unique levels and use the taxonomies for the non-unique levels.

1. Post Relationships:
- Fabricantes (manufacturers)
-- Modelos (models)
--- Versiones (versions)

2. Custom Taxonomies:
- Años (year)
- Motor (engine)

#2336401
brand.png

Hi Waqar,

I'm doing it, but for some reason it's not exactly working.

Manufacturers
-Models

+

Custom tax:
Versions
Engines

You can check here:

hidden link

Plus I'm having some very strange issues with the archive post in general.
The strangest is that the custom search Versions is checked by default in a Versions 'because' I can't uncheck it, which basically breaks everything, including changing page. < which is making me think maybe that's the reason the relationship filters dont' work... I'll check.

Another issue with the archive is (I'll give you a clear example):
hidden link < brands SKUs starting with L = Litton, at the bottom SKUs startng with LPR are a different brand.
You can check the products, there's a dynamically generated image that's the brand logo of the product. For some reason it only shows the brand of the first product on all products even if it's a different brand.

hidden link

Here you can see the same issue: PD = FRASLE brand and lower LPR = another brand same logo and to the total bottom L = Litton yet another brand.

#2336499

Sorry Waqar, can't edit:

hidden link
You can check here also, every product in this category has a Model relationship yet the custom search is empty.

#2336925

Update on what's up with this:
Relationships working OK with the custom search.

Custom tax search, I had to take it out because it was always preselected and couldn't change it (tried)
and the issue with the dynamic image persist and I don't think it's a caching issue since I tested it with all cache disabled.

#2338815

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

It is normal and expected that on the taxonomy archive page, the current term is automatically selected in the respective search field/filter. The purpose of a term archive page is to show posts/results with a specific taxonomy term.

For a fully customizable generic search, where it is possible to search through any criteria, a regular page with a post view should be used and not the archive page.

For incorrect images, I'll need to see how the archive is set up in the admin area. Can you please share temporary admin login details?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

#2340423

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access.

1. In the query filter settings of the view "marcas-imagenes", I've selected the option "Set by the current post", and the correct brand images are showing on the archive pages, now.
( screenshot: hidden link )

2. In the WordPress Archive "wooArchive", the option "Show only filter options that would produce results" is selected in the "WordPress Archive Search" block's settings.
( screenshot: hidden link )

If you'd like all search fields and options to show regardless of whether some results exist or not, you can disable this option. After making these changes clear all involved caches and then check the archive pages again.

In case you still see something out-of-place in terms of search field options or search results, please share the exact steps to see the issue and I'll investigate it, accordingly.

#2340433
preselected2.png
preselected.png

Thank you Waqar!

So the issue with the custom search filter is that an option get preselected and its the only instance that is happening.
hidden link
I took the Versiones filter out while I was trying other stuff so that's my bad, but I'll annex pics too.
I'm not sure what the issue is, and as you can see in the motores filter, it's blank same goes for the relationship filters.

#2341189

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for making this clearer.

During troubleshooting and testing, I noticed that using the term slug "00" for the "Versiones" term "00 ->" is causing this.
( screenshot: hidden link )

For the default/empty taxonomy search field select option, the '0' value is used. But, when any of the terms also have a slug with only '0's (e.g. 00, 000, 0000, etc), that term's option is treated the same as the default/empty option and gets pre-selected.

To avoid this, please change the slug for the "Versiones" term "00 ->" to anything other than all '0's value, like "base" or "default" etc.