Sto riscontrando problemi durante il caricamento di una presentazione di componenti dinamici dal broker in base a una query abbastanza semplice come quella di seguito, in cui sto tentando di caricare il componente in base al taggato con una parola chiave specifica:Tridion 2009 SP1 Broker non restituisce risultati
private string GetComponentPresentations()
{
Logger.Log.Info("Entered GetComponentPresentations");
var publicationCriteria = new PublicationCriteria(_publicationId);
int schemaId = int.Parse(SchemaId.Split('-')[1]);
// Is it the correct content type (Schema)
var isSpecifedSchema = new ItemSchemaCriteria(schemaId);
// Type of the item is 16 (Component).
var isComponent = new ItemTypeCriteria(16);
// All of the above conditions must be true
Criteria isCorrectComponent = CriteriaFactory.And(isSpecifedSchema, isComponent);
var publicationAndIsComponent = CriteriaFactory.And(publicationCriteria, isCorrectComponent);
//Only get components tagged with the specified keyword
var keywordCriteria = new KeywordCriteria(_productsCategoryTcmId, ProductFilter, Criteria.Equal);
//Only get Components of the correct type from the correct publication
Criteria fullCriteria = CriteriaFactory.And(publicationAndIsComponent, keywordCriteria);
using (var query = new Query(fullCriteria))
{
string[] results = query.ExecuteQuery();
using (var cpf = new ComponentPresentationFactory(_publicationId))
{
if(results != null)
{
var resultString = new StringBuilder();
foreach (string componentTcmId in results)
{
Logger.Log.Info("Looping over results");
int componentId = int.Parse(componentTcmId.Split('-')[1]);
int templateId = int.Parse(TemplateId.Split('-')[1]);
ComponentPresentation cp = cpf.GetComponentPresentation(componentId, templateId);
if (cp != null && !string.IsNullOrEmpty(cp.Content))
{
resultString.Append(cp.Content);
Logger.Log.InfoFormat("Appended Content {0}",cp.Content);
}
}
Logger.Log.Info("Returning");
return resultString.ToString();
}
Logger.Log.Info("Results was null.");
return string.Empty;
}
}
}
posso vedere la voce nella tabella ITEMS_CATEGORIES_AND_KEYWORDS nel database Broker con la parola chiave mi aspetto e posso caricare manualmente il CP se io commento la query e hardcode il TCM ID in.
ho assicurati che la Categoria sia pubblicata e che tutti i valori delle variabili siano corretti.
Ho assicurato che la parola chiave ha un valore e una chiave impostata sul valore appropriato.
Cos'altro posso controllare?
Query non sembra avere questo metodo. Non sono sicuro di quello che ci dice .. –