1

I have duplicated the site to create new site. I am seeing on new site some values in drop down are coming from existing site. I want to find list of items and fields for which value are coming from old site. How we can achieve this.

2
  • Hi Aman, welcome to SSE. Is this SXA site ? Dec 14, 2023 at 11:50
  • No. Its not SXA Site
    – aman
    Dec 14, 2023 at 11:56

1 Answer 1

0

You can use this approach and update the script accordingly. To compare two Sitecore instances and find duplicate items based on a specific field, you can create a PowerShell script that retrieves items from both sites and compares the values of the chosen field. Here's an example script to get you started:

# Site A
$siteAPath = "/sitecore/content/SiteA"
$siteAField = "Title"

# Site B
$siteBPath = "/sitecore/content/SiteB"
$siteBField = "Title"

# Get items from Site A
$siteAItems = Get-ChildItem -Path $siteAPath -Recurse

# Get items from Site B
$siteBItems = Get-ChildItem -Path $siteBPath -Recurse

# Hashtable to store encountered field values in Site A
$siteAFieldValues = @{}

# List to store duplicate items
$duplicateItems = @()

# Populate hashtable for Site A
foreach ($siteAItem in $siteAItems) {
    $fieldValue = $siteAItem[$siteAField]
    $siteAFieldValues[$fieldValue] = $true
}

# Compare with items from Site B
foreach ($siteBItem in $siteBItems) {
    $fieldValue = $siteBItem[$siteBField]

    # Check if the field value already exists in Site A hashtable
    if ($siteAFieldValues.ContainsKey($fieldValue)) {
        # Duplicate found, add to the list
        $duplicateItems += @{
            "SiteAItem" = $siteAFieldValues[$fieldValue]
            "SiteBItem" = $siteBItem
        }
    }
}

# Output the list of duplicate items
$duplicateItems

Modify the paths ($siteAPath and $siteBPath) and fields ($siteAField and $siteBField) according to your specific Sitecore instances and the field you want to check for duplicates. The script will output a list of items that have duplicate values in the specified field across the two sites.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.