0

My code:

        ws.CategoryConfiguration cc = new ws.CategoryConfiguration();
        cc.LoadChildProducts = true;
        cc.ChildProducts.SearchOptions.PropertiesToReturn = new string[] { "BasePrice" };

when I run this, I get a NullReferenceException on the ChildProducts line. I know that string[] is an object because it's right there, so it must be PropertiesToReturn. Anyone know what the issue is? LoadChildProducts works without any issue.

Stephen K
  • 697
  • 9
  • 26

2 Answers2

1

You need to new up the SearchOptions object, like this:

CatalogSearchOptions searchOptions = new CatalogSearchOptions();

Then you can add the PropertiesToReturn, like this:

searchOptions.PropertiesToReturn = "BasePrice";

Finally, you can assign the searchOptions to the CategoryConfiguration.ChildProducts.SearchOptions property, like this:

cc.ChildProducts.SearchOptions = searchOptions;
Karl Anderson
  • 34,606
  • 12
  • 65
  • 80
0

It is either the ChildProducts or the SearchOptions inside the ChildProducts.
Make sure that they get initialized in the constructor of a CategoryConfiguration

Caleb
  • 1,088
  • 7
  • 7