1

This question already has an answer here:

I got a D8 site with a newly created content type with the following fields:

  • Title
  • Ordering Number
  • Some Boolean field

The title field is allowed to be translated but the other two are not.

A view is created to show a list of all entities of this content type, showing only the title, filtering by the Boolean, and ordering by the Ordering number field.

Everything works fine for the default language. When switching to the second site language, the titles still shows in the default language.

I then added a filter criteria to filter using translation language of the context selected language. Now the title shows in the correct language but the order field and the Boolean field comes as nulls (I've ran the view query manually). The reason is apparently because these two fields are not translatable and hence when joined using the current language there are no corresponding records.

What is the solution for such a situation?

Query from the current view settings looks like the following:

SELECT node_field_data.langcode AS node_field_data_langcode,
node__field_order.field_order_value AS node__field_order_field_order_value,
node_field_data.nid AS nid FROM  {node_field_data} node_field_data
LEFT JOIN {node__field_order} node__field_order ON node_field_data.nid = node__field_order.entity_id AND (node__field_order.deleted = '0' AND node__field_order.langcode = node_field_data.langcode)
WHERE (( (node_field_data.status = '1') AND (node_field_data.langcode IN  ('en')) AND (node_field_data.type IN  ('my_content_type')) ))
ORDER BY node__field_order_field_order_value ASC

I had to remove the filter by Boolean because when it comes as null, no results show at all.

marked as duplicate by Berdir 8 Jan 10 '17 at 19:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • See the question I marked this a a duplicate of, this is a core bug – Berdir Jan 10 '17 at 19:09
  • I tried the patches there, but it doesn't work for Drupal 8.2.x yet – Bishoy Jan 11 '17 at 3:58

Browse other questions tagged or ask your own question.