Edit file File name : README.md Content :# Quicklly Google Merchant Product Upload This project automates the upload and deletion of products to Quicklly’s Google Merchant Center using the Content API. --- ## 📁 Project Structure ``` Google Merchant Product Upload/ ├── merchant_upload.py ├── requirements.txt ├── README.md ├── handoff.pdf ├── keys/ │ └── quicklly-merchant-center.json ├── tools └── delete_all_products.py └── delete_select_products.py ``` --- ## Setup Instructions ### 1. Create a Virtual Environment (Optional but Recommended) ```bash python3 -m venv env source env/bin/activate ``` ### 2. Install Dependencies ```bash pip install -r requirements.txt ``` --- ## Credentials Setup Place the provided **`quicklly-merchant-center.json`** file in: ```bash ./keys/quicklly-merchant-center.json ``` Make sure this matches the path in your script: ```python SERVICE_ACCOUNT_FILE = './keys/quicklly-merchant-center.json' ``` --- ## Running the Script ```bash python merchant_upload.py ``` --- ## Deleting Products Delete a single product by offerId Use this to quickly remove an individual product from Google Merchant Center: ```bash python tools/delete_product.py <offerId> ``` Delete all products (use with caution!) Wipes the entire product catalog. Use only for staging/testing environments or after confirmation: ```bash python tools/delete_all_products.py ``` ## Automating with Cron ### Every 2 Minutes ```bash */2 * * * * /usr/bin/python3 /path/to/Google\ Merchant\ Product\ Upload/merchant_upload.py >> /var/log/merchant_upload.log 2>&1 ``` ### Every 2 Hours ```bash 0 */2 * * * /usr/bin/python3 /path/to/Google\ Merchant\ Product\ Upload/merchant_upload.py >> /var/log/merchant_upload.log 2>&1 ``` > Ensure proper file permissions and review log output regularly. --- ## Regional Inventory Mapping The script automatically assigns products to predefined regions based on the product’s `"city"` field using a dictionary like: ```python CITY_TO_REGION_ID = { "chicago": "region_chi", "new york": "region_nyc", "los angeles": "region_la", "san francisco": "region_sf" } ``` If a product’s city doesn’t match this mapping, no regional inventory will be sent. --- ## How to Expand to Hundreds of Regions 1. In Google Merchant Center, go to: ``` Products → Regional availability and pricing → Region definitions ``` 2. Create new regions with: - A **region ID** (at least 6 characters, e.g., `region_dallas`) - A large enough set of ZIP codes (30–100+ per region is recommended) 3. Update your script's mapping: ```python CITY_TO_REGION_ID["dallas"] = "region_dallas" ``` For large-scale rollout, this mapping can also be loaded from a CSV, database, or admin panel. --- ## Notes - **Merchant ID:** `5616033984` - **API Scope:** `https://www.googleapis.com/auth/content` - **Region:** `US` Save