Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label sitecore 9. Show all posts
Showing posts with label sitecore 9. Show all posts

Friday, November 2, 2018

Sitecore PowerShell Script: Change alt value of image items in Sitecore media library

Sitecore PowerShell Script to change media items alt tag with image description or display Name or item name

$mediaTemplateName = "Image"
$mediaParentPath = "master:/sitecore/media library/Project"
$counter = 1

$allMediaItems = Get-ChildItem -Path $MediaParentPath -Recurse
$filteredMediaItems = $allMediaItems | Where-Object { $_.Fields["Alt"].Value -eq "" -and [Sitecore.Data.Managers.TemplateManager]::GetTemplate($_).InheritsFrom("Image") }

foreach($MediaItem in $filteredMediaItems) {
        $altValue = $MediaItem.ImageDescription

        if($MediaItem.ImageDescription -eq "" -and $MediaItem.DisplayName -ne "")
            $altValue = $MediaItem.DisplayName.Replace(".jpg", "").Replace(".JPG", "").Replace(".png", "").Replace(".PNG", "").Replace(".gif", "").Replace(".GIF", "")
        elseif($MediaItem.ImageDescription -eq "" -and $MediaItem.Name -ne "")
            $altValue = $MediaItem.Name

        #Update Alt tag
        $MediaItem.Fields["Alt"].Value = $altValue

        Write-Host $counter " -> " $altValue " -> " $MediaItem.ItemPath
        $counter = $counter + 1

Any suggestions or improvements are most welcome.

Friday, October 19, 2018

ebook : SharePoint to Sitecore: Strategy and Implementation

Sharing my 6th eBook with Sitecore community - "SharePoint to Sitecore: Strategy and Implementation".

SharePoint to Sitecore
SharePoint to Sitecore

There are multiple ways to move data and images from SharePoint to Sitecore. I tried my best to include all the approaches but explained one approach which worked for me in Sitecore 9 update 1 instance.

You can read and download this ebook from here:

I hope you like this eBook.

Please leave your comments or share this eBook if it’s useful for you.

Friday, October 12, 2018

Sitecore installation 503 error : digged the mountain and found a rat

I was installing Sitecore 9 update 1 on desktop machine with Windows 10 Enterprise as OS and IIS 10.

At "UpdateSolrSchema : SitecoreUrl" stage, I received this error

[---------------------------------------- UpdateSolrSchema : SitecoreUrl ---------------------------------------------
Install-SitecoreConfiguration : Error requesting
The remote server returned an error: (503) Server Unavailable.
User Name         habitat\user1
Install-SitecoreConfiguration : Error requesting The remote server returned an error:
(503) Server Unavailable.
At C:\code\install-xp0.ps1:272 char:9
+         Install-SitecoreConfiguration $SitecoreConfiguration `
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration

When I checked my new Sitecore website were available in IIS, but when I try to run them , I was getting 503 errors.

I googled it find out that its something related with Windows 10 patches.
I tried different solutions suggested by developers like App pool settings, permission, SOLR availability issues but none of them work for me.


My initial doubt  was on Windows 10 Enterprise machine as I done the installations on Windows 10 Professional several time and didn't encountered any issue. After spending several hours Windows 10 Enterprise OS seems to be fine and have all the patches in place.

This machine was running in client office environment. So their IT team using proxy to access internet. This proxy is blocking all local websites to run in browser. When I disabled this, my Sitecore applications started to work.

To disabled proxy
Open Internet explorer -> Goto Tools Menu -> Select Internet Options -> Click Connections Tab -> Click on LAN Settings Button -> Disabled checkbox of Proxy 

server section.

Proxy Settings in Internet Explorer
Proxy Settings in Internet Explorer

I spend 2 days to figure out this issue. I dug up the mountain and all I could find was a dead rat.

I hope this tip will help somebody to resolve similar issue.