Closed mattbarry closed 2 years ago
@mattbarry that should be pretty doable. The Add method you're looking to overload is here: https://github.com/blipson89/Synthesis/blob/main/Source/Synthesis/StandardTemplateItem.cs#L375
If I recall correctly, adding items with explicit IDs is a little funky because Sitecore doesn't expose an overload for that either, but it's doable.
If you were to submit a PR for it, please name the method AddWithSpecificId
rather than an overload for Add
. Using a specific ID is not a common use case and I don't want people thinking that they need to provide an ID.
Released in 9.1.5 - thank you again @mattbarry!
Give it a shot and if it fixed your problem, please go ahead and close this out
Looks good. Thanks @blipson89!
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
I have a use case where I'm generating new Sitecore item IDs via a hash of a unique identifier from an external datasource (similar to what Sitecore Commerce does for product synchronization). I'd like to be able to call IStandardTemplateItem.Add(name, newItemID), however this overload does not exist. Currently you would have to do something like this:
IStandardTemplateItem.InnerItem.Add(name, GetTemplateIDUsingReflection(), newItemID);
Where GetTemplateIDUsingReflection() would be custom-implemented because Synthesis doesn't publicly expose this logic.
What is the expected behavior?
I would like to submit a PR that adds an IStandardTemplateItem.Add() overload that calls Sitecore's Item.Add(name, templateID, newItemID) so that I do not need to use a hacky extension method or replicate the Synthesis logic for retrieving template IDs from a generic type.
Please mention your Sitecore version and Synthesis version.
Sitecore 9.3.0 and Synthesis 9.1.0.4