Closed (fixed)
Project:
Similar By Terms
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Aug 2012 at 17:49 UTC
Updated:
28 Jul 2026 at 15:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
luksakCould the maintainer please make a statement here?
Comment #2
quicksketchI don't think it would be too difficult, but I don't plan on implementing it because it's unneeded for the situations in which we've used this module. I'd be happy to look at patches to add this functionality.
Comment #3
luksakOk, I guess I will give it a shot in a few weeks.
Comment #4
luksakI was not able to try this. Maybe I will get a budget for this in the next few months...
Comment #5
sill commentedI'd love to see this feature implemented. For my situation it would be helpful in the case of tagging images.
Comment #6
playfulwolf commentedI am upping this to major, and changing the version.
Right now working on the "quick" views based solution for this.
Comment #7
luksakLooking at this once again, I realized that the module uses the
taxonomy_indextable, which is an index of the references between nodes and taxonomy terms. Either we need to introduce a table that holds data for all entity types or we need to run much more complex queries...Has anyone made progress on this?
Comment #8
luksakI just realized that there is this module that provides an index for any entity type: https://www.drupal.org/project/taxonomy_entity_index
Here is the core issue regarding this: https://www.drupal.org/project/drupal/issues/1040786
Comment #9
luksakI worked on this for a bit. I managed to get the dynamic queries right, except for the one in
SimilarTermsArgument.Changing this
$this->query->addTable('taxonomy_index', NULL, NULL, 'similarterms_taxonomy_index');to this
$this->query->addTable('taxonomy_entity_index', NULL, NULL, 'similarterms_taxonomy_index');Causes the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'similarterms_taxonomy_index.tid' in 'where clause': SELECT "commerce_product_field_data"."langcode" AS "commerce_product_field_data_langcode", COUNT(commerce_product.product_id) AS "commerce_product_product_id", MIN(commerce_product_field_data.product_id) AS "product_id" FROM {commerce_product_field_data} "commerce_product_field_data" INNER JOIN {commerce_product} "commerce_product" ON commerce_product_field_data.product_id = commerce_product.product_id WHERE (("similarterms_taxonomy_index"."tid" IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) AND ("similarterms_taxonomy_index"."entity_type" IN (:db_condition_placeholder_3)) AND ("commerce_product"."product_id" NOT IN (:db_condition_placeholder_4))) AND ("commerce_product_field_data"."status" = :db_condition_placeholder_5) GROUP BY commerce_product_field_data.product_id, commerce_product_field_data_langcode ORDER BY "commerce_product_product_id" DESC LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_0] => 22 [:db_condition_placeholder_1] => 28 [:db_condition_placeholder_2] => 29 [:db_condition_placeholder_3] => commerce_product [:db_condition_placeholder_4] => 2716 [:db_condition_placeholder_5] => 1 )There seems t be a missing relationship between the sql tables and therefore a join is missing from the query.
I also tried to use a left join, but somehow without success:
Does anyone know how to solve this?
Comment #11
luksakOk, i got this working with my patch in #3222950: Provide views join on BASE_TABLE_field_data!
Cleaned up my patch a bit in the merge request.
Comment #12
calbasiIt seems your patch can NOT be applied on last module versions 1.8.0:
Comment #13
luksakOk, here is a re-roll.
Comment #14
loze commentedThanks, this got it working for me with commerce_product entities, and think this is on the right track.
This also needs to do the following.
1. Check if the taxonomy_entity_index module exists first and only perform these changes if it does.
2. Instead of just supporting commerce_product entities it should loop through all available content entities and provide the joins for any content entity.
I need this for my project so I will try to provide a patch.
Comment #15
loze commentedI've made some updates to the MR.
1. It checks if taxonomy_entity_index is enabled, and defaults back to using the taxonomy_index table if it is not.
2. the views fields/args now supports all content entities.
I have also updated the MR for taxonomy_entity_index on #3222950: Provide views join on BASE_TABLE_field_data which is required for this to work.
Everything appears to be working as expected on my local site and I can now use this module with products and other entities.
attached is a patch for composer
Comment #16
shelaneComment #17
loze commentedRebased onto the current 8.x-1.x. The module has changed a lot since this MR was written, so the changes were redone on top of the current code rather than merged.
The behavior is the same as before: with taxonomy_entity_index installed, the similarity argument, field, and sort work for all content entity types, not just nodes. Without taxonomy_entity_index installed, nothing changes.
One difference: the current code builds its own join to the index table, so this no longer depends on #3222950: Provide views join on BASE_TABLE_field_data.
Added tests for non-node entities. Pipeline is green.
Comment #19
shelaneThank you for updating the patch. I merged it and then realized that there was nothing added to the README about the new functionality. Can you submit that information?
Comment #20
shelaneComment #22
loze commentedUpdated Readme in !14
Comment #24
shelane