I am retrieving components in a specified folder using Core Services to build an API to expose some content. We have a preview and live environment and I need to retrieve components that have been published to the "live" environment only
code being used for retrieving components:
private static void LoadExistingProducts()
{
LinkToSchemaData[] schemaLinks = new[] {
new LinkToSchemaData {
IdRef = ConfigurationManager.AppSettings["productSchema"]
}
};
// Define a filter to return only Components.
OrganizationalItemItemsFilterData componentFilter = new OrganizationalItemItemsFilterData
{
ItemTypes = new[] { ItemType.Component },
BasedOnSchemas = schemaLinks
};
//get xml list of existing product components
existingProducts = client.GetListXml(
ConfigurationManager.AppSettings["productComponentFolder"],
componentFilter);
ComponentData component = null;
XmlSerializer serializer = new XmlSerializer(typeof(Tridion_Product));
foreach (XElement element in existingProducts.Elements())
{
component = (ComponentData)client.Read(element.Attribute("ID").Value, null);
StringReader readr = new StringReader(component.Content);
MyReader reader = new MyReader(readr);
Tridion_Product product = serializer.Deserialize(reader) as Tridion_Product;
//Place deserialized version of existing object in dictionary for comparison step
ProductDictionary.Add(product.ProductID, product);
}
}