question

NJ avatar image
NJ asked

Economy category item one to many relationship

Hello, I've one to many relationship category and item. item can have only one category and category can have many items such as:

{
  "Categories": [
    {
      "name": "hair",
      "items" : [
        {"name": "hair-1"},
        {"name": "hair-2"}
      ]
    },
    {
      "name": "eyes",
      "items" : [
        {"name": "eye-1"},
        {"name": "eye-2"}
      ]
    }
  ],
}

I am confused where is the right place in playfab to store categories (hair, eyes). For items it's simple I can save them in Economy -> Catalog -> Items(hair-1, hair-2, eyes-1, eyes-2). But for categories it's confusing. Is the title data right place to store categories? Also should I specify category in item's -> item class or in item's -> tag?

Title DataIn-Game Economydata
10 |1200

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

1 Answer

·
Made Wang avatar image
Made Wang answered

You can define item categories in the Item->Item class. Item Tag also implements the similar feature, but items cannot be sorted by Item Tag in Game Manager. You can refer to Catalogs - PlayFab | Microsoft Docs to learn more.

In addition, Title data is not attached to the item, so it is not suitable for storing item categories.

2 comments
10 |1200

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

NJ avatar image NJ commented ·

But I also want to store additional information about categories, such as icon and other properties. So I need to define them separately. One option is to save this information inside item's custom data but this will cause a lot of duplication. Another option is to save categories separately ( for example in title data) and link them to items via item class property. But I am not sure if it's the best practice

0 Likes 0 ·
Made Wang avatar image Made Wang NJ commented ·

Do icons and properties under the same category need to be reused?, if so, you can save data templates of different categories in Title Data, and then use GetTitleData to get the template. If you need to update the data in the item or create a new item, you can call UpdateCatalogItems, SetCatalogItems, etc.

One thing to note is that Title Data works best with global constants/static data, updates can be delayed up to 15 minutes, refer to Title Data - PlayFab | Microsoft Docs to learn more.

You can also use Duplicate in Game Manager->Economy->Catalog to generate items of the same category or use Bulk edit to modify items of the same category.

0 Likes 0 ·

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.