Often when i need to figure this out, i use SQL Management studio to take a look at the table structure to see where the relationship is stored.
In the database i see a COM_SKUOptionCategory, COM_OptionCategory, however these may be more partaining to Sku Options than Skus.
SKUs also have an associated Document ID if they are not a sku option or something similar, so the relationship may be in the DocumentCategory Table.
I'm sorry i don't have the time to create a test, but this is what i would do.
- Add a category to a sku
- Check to see if that relationship is between the SKU's Document (in CMS_DocumentCategory), or if it's in the COM_SKUOptionCategory table.
- Once you have that, use this macro, adjusting the where condition:
SiteObjects.SKUs.Where("the where condition here").FirstItem
The where condition will depend on where the relationship is, but something like SKUID in (Select SKUID from _______ where CategoryID = (select top 1 CategoryID from THEJOINTABLE where CategoryName = 'mycategory'))