Skip to content

Automatic script for locating and patching variables through API calls based on relationship mapping of items.

Notifications You must be signed in to change notification settings

BLibs/Primo_Modifier_Patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Primo Product Modifier Group Patch

This script gets a user input for which mod they recently updated the price of, uses the attached XLSX files to locate all items that default to this modifier, run those items through a function to get all data for the associated mods, sums the price of the default mods, and patches the associated product modifier group with the updated "free" price.

Table of Contents

Introduction

Each item has a unique modifier group attached to it for holding the available modifiers, their price, and which ones are default on the item. The modifier groups leverage a "free" variable, which states that if Example comes with American Cheese ($3.00) and Provolone Cheese ($4.00) by default, there is an applied free modifier value of $7.00 on Example. If the customer chooses to replace American Cheese with Swiss ($5.00), then the difference of $2 should be applied to the price of the item at checkout. The issue here is that the free field is hardcoded, and as the price of modifiers change, the value that is free will no longer line up with the cost of the mods. This required manual patching of each free variable in each modifier group, with an average of 4 modifier groups per item, across 3,854 current items, and a quickly growing number of ~120 establishments. That came out to roughly 1.8 million variables that would need to be patched if the price of all mods changed!

To combat this problem, the script links the items to their modifiers using the only constant they share across all establishments, their SKU. When the user selects American Cheese now, all items that come with American Cheese by default will be put into a list and patched automatically. The data is pulled across various endpoints, the updated modifier prices are summed and compared to the free variable, and if they do not match anymore, the free field will be overwritten by the sum of the deafult mods and patched accordingly. This script takes what used to be a long tedious process and simplifies it dramatically.

Features

  • Locates all impacted items when a specific modifier is selected
  • Targets a specific establishment
  • Automatically patches the items

Installation

  1. Clone the repository:
    git clone https://github.com/BLibs/Primo_Modifier_Patch.git
  2. Navigate to the project directory:
    cd Primo_Modifier_Patch
  3. Install the required dependencies:
    pip install -r requirements.txt

Configuration

Update the config.py file in the project directory and define the following API variable:

API = "APIKEY"

Usage

The script can either be ran directly as a Python file or compiled into an .exe with Pyinstaller

  • Run the script to start the automation process:
    python main.py
  • Compile the .exe which can then be ran in any environment.
    pyinstaller --onefile --clean main.py
    

Improvements

  1. Swap out Threading for process based concurrency. Something like ThreadPoolExecutor would provide better speeds and could still be coupled with Threading module for maximum performance.
  2. Move from CLI to GUI based project.
  3. Need to incorporate logging of patched mod groups in a clean and easy to read format.
  4. Look through ways to cut down on API calls.
  5. API call logging.
  6. Implement a group of frequently patched mods so they can all be run at once.
  7. Need to join threads at the end of patch function to output results and get user input to continue.

About

Automatic script for locating and patching variables through API calls based on relationship mapping of items.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages