FB_init

Thursday, March 25, 2010

Get a product in 5 lines of code

Here is how you can retrieve a product (in this case in a virtual catalog) in Microsoft Commerce Server (2009, but using 2007 API and not Foundation) with PowerShell in 5 lines:


[reflection.assembly]::loadwithpartialname(“Microsoft.CommerceServer.Catalog”)
$catalogAgent = new-object -typename Microsoft.CommerceServer.Catalog.CatalogServiceAgent -argumentlist (“http://localhost/DefaultSite_CatalogWebService/CatalogWebService.asmx”)
$catalogContext = [Microsoft.CommerceServer.Catalog.CatalogContext]::Create($catalogAgent)
$catalog = $catalogContext.GetCatalog("MyVirtualCatalog")
$product = $catalog.GetProduct("AW099-15(Adventure Works Catalog)")

No comments: