API
Version 7.x > API > Setting SKU Publish To value? View modes: 
User avatar
Member
Member
matt-awg - 10/31/2013 2:14:43 PM
   
Setting SKU Publish To value?
I am trying to use the API to hide a SKU from showing on the site by using the "Publish TO" value and setting the date to now. If I go to the CMS Desk, browse to the product in the content tree and set the flag, it works fine, but I can't seem to figure out how to set it via the API. Is this not possible? I have this sudo code:
            For Each productDoc As SKUTreeNode In tnds.Items
'productDoc.DocumentPublishTo = Now() 'THIS IS READONLY
productDoc.SetValue("PublishTo", Now()) 'so I tried this

productDoc.Update()
Next

The DocumentPublishTo property is read only so that won't work. The SetValue did not throw an error but that did not actually update the field. I can't find anything else in the API documentation to try... Any ideas what I am missing?

Thanks,
Matt

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 10/31/2013 3:29:47 PM
   
RE:Setting SKU Publish To value?
Why are you trying to set it? It sounds like all you want to do is compare the value to the current date, and then use this to control the display or visible property. Why not use the front end as it is and then set a where condition in the repeater or code behind that will compare the date and set that property.


Is this what you are trying to do or is there a reason that you want to update that value?

User avatar
Member
Member
matt-awg - 11/1/2013 9:44:22 AM
   
RE:Setting SKU Publish To value?
josha-bpstudios - thanks but the goal is creating middle-ware that updates this field... it has nothing to do with the front end. The site is already hiding products based on this field, I just need the ability to set it via middle-ware.

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/1/2013 4:08:43 AM
   
RE:Setting SKU Publish To value?
Hi,

The reason this is not working is that the column name is different then PublishTo.
What you are looking for is:
productDoc.SetValue("DocumentPublishTo", Now());

Let us know how it works.

Kind regards,
Richard Sustek

User avatar
Member
Member
matt-awg - 11/1/2013 9:44:41 AM
   
RE:Setting SKU Publish To value?
Thanks Richard! That was it!!!