Is it possible to exclude particular content from the sync?
We have a shop section where the products are synchronised from another system, so synching them through converge is not required, would be handy to have some kind of exclusion list.
Hi Huw, there is a way to set the default action for certain content, in this case you can automatically set it to Ignore. Take a look at the "Default Action Setter" section in the documentation.
I can immediately see that this is quite limiting as you only have the name to go on. I will take a look at including the path in the GetDefaultAction() function.
Another approach could be to set up specific users on both the remote and local sites and use Umbraco permissions to stop access to the shop section. Then use those users when using Converge.
I realised earlier that just having the name would be limiting. Currently working on adding the path to that function, that will allow you to identify the position in the content tree.
The only other solution I can think of is to use the ContentService within the DefaultActionSetter to check if it is a "product". Something like (untested):
var productContentType = Umbraco.Core.Composing.Current.Services.ContentTypeService.Get("product");
if (productContentType != null)
{
long numRecords;
var productContent = Umbraco.Core.Composing.Current.Services.ContentService.GetPagedOfType(productContentType.Id, 0, int.MaxValue, out numRecords, null).FirstOrDefault(c => c.Name == itemName);
if (productContent != null)
{
action = MergeAction.Ignore;
}
}
Not sure how you set up the "filter" parameter, but that may help. You could pre-load products into a List<string> if speed is an issue.
Thanks for info, I will try that, theproducts do exist in both local and remote, I just don't want to synch incase the prod version has had any properties updated (description/image etc, but they should at least exist in both systems.
I notice that in your latest version you added a path parameter to the GetDefaultaction on Action setters, could you perhaps provide a quick example of that works?
I added the path parameter to provide a bit extra information. You can ignore it if you don't need it. It is a "\"-separated list of this item's ancestors. Each name in the list is URL-encoded and can be decoded using HttpUtility.UrlDecode().
For example, this will ignore all the local-only nodes under "\Home\Ignore Local Folder":
if (contentType == ConvergeContentType.Content)
{
if (!String.IsNullOrWhiteSpace(path))
{
var parents = path.Split('\\');
if (parents.Length > 2 && status == CompareStatus.LocalNotRemote)
{
// path starts with "\", so ignore parents[0] - it is blank
if (HttpUtility.UrlDecode(parents[1]) == "Home" && HttpUtility.UrlDecode(parents[2]) == "Ignore Local Folder")
{
mergeAction = MergeAction.Ignore;
}
}
}
}
The actual path string provided will look like this (as the components are Url-encoded): "\Home\Ignore+Local+Folder"
excluding specific content when synchronising
Is it possible to exclude particular content from the sync?
We have a shop section where the products are synchronised from another system, so synching them through converge is not required, would be handy to have some kind of exclusion list.
Hi Huw, there is a way to set the default action for certain content, in this case you can automatically set it to Ignore. Take a look at the "Default Action Setter" section in the documentation.
I can immediately see that this is quite limiting as you only have the name to go on. I will take a look at including the path in the GetDefaultAction() function.
Another approach could be to set up specific users on both the remote and local sites and use Umbraco permissions to stop access to the shop section. Then use those users when using Converge.
Thanks for the pointer, I will take a look at creating an action setter for my products.
Hi Stuart,
I gave it a try, but don't see how I can get it to ignore all the products
Basically I have a Shop page that has children who are 'product' (doc type alias) created as below
I want to ignore all these 'product' when synching, can't see how I do that using the defaultactionsetter interface,
I realised earlier that just having the name would be limiting. Currently working on adding the path to that function, that will allow you to identify the position in the content tree.
The only other solution I can think of is to use the ContentService within the DefaultActionSetter to check if it is a "product". Something like (untested):
Not sure how you set up the "filter" parameter, but that may help. You could pre-load products into a List<string> if speed is an issue.
That would only work if the product exists locally.
Thanks for info, I will try that, theproducts do exist in both local and remote, I just don't want to synch incase the prod version has had any properties updated (description/image etc, but they should at least exist in both systems.
worked a treat, thanks for the help.
Hi Stuart,
I notice that in your latest version you added a path parameter to the GetDefaultaction on Action setters, could you perhaps provide a quick example of that works?
Your code is a godsend by the way :)
Glad it's proving useful Huw.
I added the path parameter to provide a bit extra information. You can ignore it if you don't need it. It is a "\"-separated list of this item's ancestors. Each name in the list is URL-encoded and can be decoded using HttpUtility.UrlDecode().
For example, this will ignore all the local-only nodes under "\Home\Ignore Local Folder":
The actual path string provided will look like this (as the components are Url-encoded): "\Home\Ignore+Local+Folder"
Many thanks for the explanation.
is working on a reply...