1

I am trying to fetch keywords using 'GetTaxonomyKeywords' but its getting me null.

I have published my Taxonomy and entries are there in the Broker DB.

I have referred blogs like (https://code.google.com/p/dynamic-delivery-4-tridion/source/browse/trunk/dotnet/DD4T.Providers.SDLTridion2011sp1/TridionTaxonomyProvider.cs) for coding.

Am I missing anything here? I tried even putting "Taxonomy" item entry in my storage config.

My calling code :

taxonomy = tax.GetTaxonomyKeywords(
    "tcm:55-2297-512", 
    compFilter, 
    new TaxonomyHierarchyFormatter()
);
2
  • You could try to enable hibernate logging (see tridion.stackexchange.com/questions/2808/… for more info on how to do this). This will show you the actual DB queries that the broker executes. It's not the answer to your question, but it might help you to debug your problem. Commented Oct 22, 2014 at 7:24
  • Thanks Harald, but i have already seen the logs and query is getting formed and returning no results. Though I doubt the query "select distinct *... " I think it should form "select *" but I don't know if I need to change the code or some config settings
    – user918
    Commented Oct 26, 2014 at 5:59

1 Answer 1

1

try this code

public static IEnumerable<Keyword> GetKeywords(string categoryUriToLookIn)
    {
        TaxonomyFactory objTaxonomy = new TaxonomyFactory();

        // Create filter to retrieve all keywords in a taxonomy
        CompositeFilter compFilter = new CompositeFilter();

        // Get keywords in taxonomy (hierarchically)
        IEnumerable<Keyword> taxonomy = null;

        try
        {
            // Ugly way to see if a taxonomy exists. Alternative is to loop through all taxonomys in Tridion and check if the categoryUriToLookIn exists...
            taxonomy = objTaxonomy.GetTaxonomyKeywords(categoryUriToLookIn, compFilter, new TaxonomyHierarchyFormatter()).KeywordChildren.Cast<Keyword>();


        }
        catch (Exception ex)
        {
            //Log.Debug("There has been an error retrieving taxonomy: " + ex);
        }

        if (taxonomy != null)
        {
            // Search in taxonomy
            foreach (var currentKeyword in taxonomy)
            {
                // Return keyword
                yield return currentKeyword;
            }
        }
    }
1
  • I am using the same code Abdul.
    – user918
    Commented Oct 26, 2014 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.