We have requirement to get the Last Published Date of Component in tridion DXA 1.2
Is there any DXA OOTB method to get the LastPublishedDate from Broker DB?
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It only takes a minute to sign up.
Sign up to join this communityWe have requirement to get the Last Published Date of Component in tridion DXA 1.2
Is there any DXA OOTB method to get the LastPublishedDate from Broker DB?
I would advise you not to get information directly from the Items table of the Content Delivery database. It is not supported and the database structure may be changed at any time (e.g. with a hotfix or version update). There is a supported API for retrieving Content Delivery data and metadata.
To find the last publication date of a page, obtain it's system metadata using the PageMetaFactory class. There is also a ComponentMetaFactory class which can give you the system metadata for components, including the last publication date, but I don't remember whether this is applicable to all components or only those which have been published using a dynamic component template.
It's not a supported solution to get data directly from the database - you would be best advised using the supported APIs.
Have you tried anything in the API such as
PageProvider.GetLastPublishedDateByUri(page.Id)
or the solution presented on TREX already?
Are you using DCPs? Read around/test when the publish date is updated - e.g. when published as a DCP and/or as a static CP on a page.