You can use below code snippet to get all the rendering on an item including renderings from page/partial design.
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.Mvc.Pipelines.Response.GetXmlBasedLayoutDefinition;
using Sitecore.Pipelines;
using System.Web.Mvc;
using System.Xml;
using System.Xml.XPath;
public static class SitecoreHelperExtensions{
public static void GetRenderings(){
var args = new GetXmlBasedLayoutDefinitionArgs();
CorePipeline.Run("mvc.getXmlBasedLayoutDefinition", args);
var xmlDefinition = args.Result;
//Get the context device definition
var deviceNode = xmlDefinition.XPathSelectElement("d[@id='" + (object)Sitecore.Context.Device.ID.ToString() + "']");
XmlDocument deviceNodeXML = new XmlDocument();
deviceNodeXML.LoadXml(deviceNode.ToString());
// Exracts rendering from the context device
Item contextItem = Sitecore.Context.Item;
var renderingReferences =
LayoutField.ExtractReferences(deviceNodeXML.FirstChild, contextItem.Language, contextItem.Database);
// code to interate through each renderings
foreach (var renderingReference in renderingReferences)
{
}
}
}
By calling above snippet SitecoreHelperExtensions.GetRenderings(), you can get all the rendering on an item merged with page/partial design renderings.
Hope this helps!!!