I have a term reference field that, because it has its options limited after 3 matching fields, will always have a single option. In order to make sure this option is selected, I set the term reference field to required. However, when trying to display the field in a view or as a node, it never appears, as if no value was stored. Is there something I'm missing?

Please note: The nodes in which this term reference field is found are being created via the Feeds module, so the 3 matching fields are being populated in a feeds import process. The end-user is not expected to manually update any of these 7581 nodes. From all of the testing I've done, only manually saving the node will "solidify" the term reference field's value (for lack of a better word). The select list itself does not have to be touched, just hitting the Save button does the trick. Using VBO's "Save Content" operation and using "node_save($entity);" in VBO PHP code do not work. The Resave Nodes module did not work. Updating the nodes via a feed import (skipping hash checks) does not work.

Comments

mctwist created an issue.

dhayalan_ms’s picture

I would like to understand the issue better , I am confused with this line "because it has its options limited after 3 matching fields, will always have a single option." Can you explain bit more clear? Are you trying to say that You have mapped term reference field against three matching fields in Feeds ex. CSV?

When you import the nodes via Feeds , the term reference field is getting updated at back-end (Database) but not displaying in the front end (Node view page) is that correct?

mctwist’s picture

Thanks for the fast reply!

The 3 matching fields are for the client's 3 types of "product codes," I guess you could call them. The issue is that when customers are searching for products, the codes won't make much sense to them, so the client has set up "Product Keywords" that are easier to understand. So, a Product Keyword is simply a term with a certain combination of options from the 3 "product code" term reference fields (Yes, the Keywords are terms that have 3 term fields within them, and yes, some can be empty). The amount of Keywords on the site is quite small (20-30), as is the options of each "product code" field. Here's a goofy example:

Product #42 has: CodeType1 = "BLT" CodeType2 = "RG3" CodeType3 = "KLM"
Product #216 has: CodeType1 = [empty] CodeType2 = [empty] CodeType3 = "KLM"

Keyword "Sloth" has: CodeType1 = "BLT" CodeType2 = "RG3" CodeType3 = "KLM"
Keyword "Muffin" has: CodeType1 = [empty] CodeType2 = [empty] CodeType3 = "KLM"
Keyword "Hot Dog" has: CodeType1 = "[empty]" CodeType2 = "RG3" CodeType3 = "KLM"

Product #42 needs to have the keyword "Sloth" automatically assigned to it, and Product #216 needs to have the keyword "Muffin" automatically assigned to it. "Hot Dog" is never the first or only choice for Product #216 because its CodeType2 selection is empty, and so is the CodeType2 field for the Keyword "Muffin."

Setting the Keyword term reference field to required allows that one option to "appear" to already be selected when going in to edit the node. I can go into phpMyAdmin and check the value of the Keyword term reference fields, but I'm quite certain they'll be empty. So, I guess my question is, how do fill it with the only option available?

dhayalan_ms’s picture

I believe the best option for you to use Migrate module. And in function prepareRow you can handle this by adding logic to import the only option available. And I believe this issue is related to Migration issue not with respect to this module