Sitecore Quick Tip: Programmatically Set Item to Not Publishable & Check If Is Publishable

Publishing

Pretty straight forward but I needed this today. To set an entire item (not just certain versions of it) to not publishable:

Now of course this by itself will not remove the item from the content delivery servers, it needs to be published, so you can follow this up with:

Which essentially says publish the item to the web database in english, do not perform a deep publish, perform a smart publish and do not publish related items.

Now more interestingly if you want to take any given item and tell whether its publishing is restricted in any way you can use the following:

This requires the using statements: