MerGroup to Commerce Category Mapping – Solution Design

Requirement

  • As a member of the Marketing Team
  • I need to be able to manage the 20,000 items and their relationships to Commerce Categories without going crazy
  • So I need the system to add and remove items from Commerce Categories based on the MerGroups(custom record) assigned to each item.

Solution Notes

  • We will create a Custom record for declaring such mapping between the MerGroup and the Category.
  • Use a map/reduce script
  • Schedule the script to run nightly on these Mapping File (MarGroup-Category Mapping Records), it will load the category and and add/remove the items with matching mergorup in the file
  • The client SHOULD NOT delete mergroup category mappings, just set them to Inactive
    • As protection, we will add a UE script to the mergroup category mapping that triggers on DELETE
      • Query the mapped commerce category
      • Iterate over the items that belong to it
      • Find any items that have the mergroup that was just deleted from the mapping record
      • Remove those items that belong to that mergroup from that commerce category

Pseudocode

  • For every Item where display in web store is true
    • For each mergroup on the Item
      • If the mergroup category mapping has the mergroup
        • Get all records from mergroup category mapping corresponding to mergroup
        • For each mergroup category mapping
          • If mergroup category mapping is active
            • Add Item to mapped category
          • If mergroup category mapping is inactive
            • Remove item from mapped category

Leave a comment

Your email address will not be published. Required fields are marked *