1

There is an item with two language versions - English & Thai. This item is already published to web.

There is a difference in the published stats when manual & programmatically published. I'm using smart publish, not publishing subitems & related items.

Manual publish:

Published only for English:

Items created:0    
Items updated:0  
Items skipped:2 

Published only for Thai:

Items created:0    
Items updated:0  
Items skipped:2  

Published English & Thai at the same time:

Items created:0    
Items updated:0  
Items skipped:6 //should this not be 4?

Publish through code:

Published only for English:

Items created:0    
Items updated:0  
Items skipped:1 

Published only for Thai:

Items created:0    
Items updated:0  
Items skipped:2  

Code:

PublishOptions publishOptions = new PublishOptions(masterDb, targetDatabase,
      PublishMode.SingleItem, sourceItem.Language, System.DateTime.Now);
Publisher publisher = new Publisher(publishOptions);
using (new SecurityDisabler())
{
    using (new EventDisabler())
    {
       PublishResult publishResult = publisher.PublishWithResult();
    }
 }

I'm guessing, it may be because I'm using PulishMode.SingleItem.
When I check the publishinglog after manual publish, it says PublishMode is SingleItem.
1. Why is the difference in the stats.
2. When publishing via code as a smart publish, which mode should be used.

1 Answer 1

3

When manually publishing any item

If you select just “English” then the English version of item you selected and English version of “/sitecore/system/Languages/en” will be queued and published [if it finds any changes] or skipped. That’s why you are seeing 2 items while selecting English alone.

If you select just “Thai” then the Thai version of item you selected and Thai version of “/sitecore/system/Languages/th-TH” will be queued and published [if it finds any changes] or skipped. That’s why you are seeing 2 items while selecting Thai alone.

If you select both English and Thai then English & Thai version of item you selected and English & Thai version of “/sitecore/system/Languages/th-TH” item and English & Thai version of “/sitecore/system/Languages/en” item will be queued and published [if it finds any changes] or skipped. That’s why you are seeing 6 items [3 items x 2 language versions] while selecting English & Thai.

When doing it from code

If you set “English” [default language comes with installation] then the English version of item you selected will be queued and published [if it finds any changes] or skipped. That’s why you are seeing 1 item while setting English.

[Language item is not queued when we set default language in code, 
need to dig into Sitecore APIs to find the reason]

If you set “Thai” then the Thai version of item you selected and Thai version of “/sitecore/system/Languages/th-TH” will be queued and published [if it finds any changes] or skipped. That’s why you are seeing 2 items while setting Thai or any other custom language.

Mode Sitecore Uses

After you publish manually when you check the publish logs you can identify mode as well as various parameters used for that particular publish.

For ex- When publishing a single item using “Publish Item” option in Sitecore, Mode used by system is “SingleItem”. At the same time if you publish the entire site then the mode set by system is “Full”.

28164 13:38:43 INFO  [PublishOptions]: root:{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9},
     language:en, targets:Internet, database:web, mode:SingleItem, smart:True children:False, 
    related:False
28164 13:38:43 INFO  [PublishOptions]: root:{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}, 
    language:th-TH, targets:Internet, database:web, mode:SingleItem, smart:True 
    children:False, related:False

Better Mode to use from Code

Purely dependent on your requirement, but if you want to publish a single item/Item by Item then I would suggest “SingleItem” will be an effective approach. **[This is what Sitecore also uses when publishing a single item manually]**

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.