question

romagoldun avatar image
romagoldun asked

How to get list of all bundles in a store in C#?

I have several stores in the game. These stores have a list of bundles. I need for each store to select the bundles that belong to it. The documentation doesn't provide examples in C#, so I'm asking you to provide one. Only Economy V2 API!

In-Game Economy
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Xiao Zha avatar image
Xiao Zha answered

You could refer to the code below to get all bundles in your stores.

 void GetBundlesInStores()
 {
     PlayFabEconomyAPI.SearchItems(new SearchItemsRequest
     {
         //get store list
         Filter = "type eq 'store'"
     }, re1 =>
     {
         foreach (var store in re1.Items)
         {
             Debug.Log("StoreId:" + store.Id);
    
             PlayFabEconomyAPI.SearchItems(new SearchItemsRequest
             {
                 //filter bundles in store
                 Filter = "type eq 'bundle'",                    
                 Store=new StoreReference { Id=store.Id },
             }, re2 =>
             {
                 foreach (var bundle in re2.Items)
                 {
                     Debug.Log("BundleId: " + bundle.Id);
                 }
             }, er2 =>
             {
                 Debug.Log(er2.GenerateErrorReport());
             });              
         }
     }, er1 =>
     {
         Debug.Log(er1.GenerateErrorReport());
     });
 }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

It may also be beneficial to look into the new Catalog Views feature we announced at GDC this year. It allows you to take a simple query like this one and cache the results to a blob in the CDN for quick and easy download at startup. Take a look.

https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/catalog-views

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.