Magento 2 + Gmail: approve and disable dead SKUs
Your Magento catalog quietly bloats over time. Old variants, test SKUs, seasonal leftovers. They don’t just “sit there” either. They clutter search, confuse shoppers, and make merchandising work feel heavier than it should.
eCommerce managers feel it when reporting starts to drift. Store owners notice it when the site looks messy. And the ops person who “owns Magento” ends up doing Magento SKU cleanup automation by hand, one filter and CSV export at a time.
This workflow finds products with zero sales in the last 12 months, emails you an approval report in Gmail, and only then disables those SKUs. You’ll learn what it does, what you need, and how to roll it out safely.
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: Magento 2 + Gmail: approve and disable dead SKUs
flowchart LR
subgraph sg0["Scheduled Run Flow"]
direction LR
n0@{ icon: "mdi:play-circle", form: "rounded", label: "Scheduled Run Trigger", pos: "b", h: 48 }
n1@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Check Items Present", pos: "b", h: 48 }
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Retrieve Orders Past Year"]
n3["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Compute Date 12 Months Back"]
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Derive Sold SKU List"]
n5["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Retrieve All Product SKUs"]
n6["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Filter Unsold Products"]
n7@{ icon: "mdi:message-outline", form: "rounded", label: "Send Approval Email", pos: "b", h: 48 }
n8@{ icon: "mdi:swap-vertical", form: "rounded", label: "Iterate Item Batches", pos: "b", h: 48 }
n9@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Approval Decision Check", pos: "b", h: 48 }
n10["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/merge.svg' width='40' height='40' /></div><br/>Combine Branch Data"]
n11@{ icon: "mdi:swap-vertical", form: "rounded", label: "Expand Unsold List", pos: "b", h: 48 }
n12["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Deactivate Products"]
n13@{ icon: "mdi:message-outline", form: "rounded", label: "Notify Deactivation Email", pos: "b", h: 48 }
n14@{ icon: "mdi:cog", form: "rounded", label: "Aggregate Product Data", pos: "b", h: 48 }
n15["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Assemble Report Email"]
n16["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Compose Approval Email"]
n1 --> n4
n9 --> n10
n10 --> n11
n14 --> n15
n11 --> n8
n8 --> n14
n8 --> n12
n12 --> n8
n0 --> n3
n16 --> n7
n5 --> n6
n15 --> n13
n7 --> n9
n4 --> n5
n2 --> n1
n3 --> n2
n6 --> n10
n6 --> n16
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0 trigger
class n1,n9 decision
class n2,n5,n12 api
class n3,n4,n6,n15,n16 code
classDef customIcon fill:none,stroke:none
class n2,n3,n4,n5,n6,n10,n12,n15,n16 customIcon
Why This Matters: Catalog Bloat That Costs You Sales
Dead SKUs create a slow leak in your store. Search results show products nobody buys, category pages get longer, and the “real” products are harder to find. Then the team compensates by adding more filters, more manual QA, and more one-off rules. It’s not dramatic in a single day. But over a month, you lose time, you lose clarity, and you risk disabling the wrong item because you’re working from a half-trusted export or an outdated report.
It adds up fast. Here’s where the manual approach usually breaks down.
- Pulling 12 months of orders and extracting SKUs turns into a recurring “half-day task” on someone’s calendar.
- Catalog-wide comparisons are easy to get wrong, especially when variants, bundles, or renamed products are involved.
- Teams delay cleanup because nobody wants to be responsible for disabling a product without review.
- When you finally do prune the catalog, there’s often no clean audit trail of what changed and why.
What You’ll Build: Monthly Unsold SKU Review + Safe Deactivation
This automation runs on a schedule (the first of every month at 8 AM). It calculates the date from 12 months ago, then pulls your Magento 2 orders created within that window through the REST API. From those orders, it builds a list of SKUs that actually sold. Next, it fetches your full product catalog, compares it against the sold list, and produces a clean “unsold products” set. You get an HTML report in Gmail with SKU, name, price, and status. You click Approve or Decline. Only if you approve will the workflow loop through the list in batches and disable those products, then email a summary of what was changed.
So you go from “someone needs to figure out what’s dead” to a consistent monthly review. Magento 2 does the data, Gmail handles the decision, and n8n performs the updates with safeguards.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Say your store has about 5,000 products. A typical manual cleanup looks like: export orders (about 30 minutes), export product catalog (another 30), build a sold-SKU list and compare (about 1–2 hours), then double-check the “unsold” list with someone else (another 30 minutes). That’s roughly 3 hours per month, and it’s easy to push off. With this workflow, you spend a few minutes reviewing the Gmail report and clicking Approve or Decline, then wait for the batch updates and the summary email. Most teams get those 3 hours back, and the results are more consistent.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Magento 2 for orders and catalog access
- Gmail to send approvals and summaries
- Magento 2 API Bearer Token (create it in Magento admin integrations)
Skill level: Intermediate. You’ll connect accounts, paste an API token, and sanity-check a few test runs before turning it on.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
A monthly schedule kicks it off. On the first day of the month at 8 AM, n8n starts the run and calculates the “12 months ago” cutoff date so the logic always stays current.
Magento order data becomes a sold-SKU list. The workflow pulls all Magento 2 orders created within the last year via HTTP requests, then extracts the SKUs that actually sold. If no orders are found, it stops, which prevents weird edge cases from causing a bad cleanup.
Your full catalog gets compared against reality. Next it fetches all product SKUs, filters out anything that appears in the sold list, and assembles an “unsold products” report with helpful context (SKU, name, price, status). This is the part you normally do with exports and spreadsheets.
Gmail collects approval, then Magento updates in batches. You receive an interactive Gmail approval email (Approve or Decline). If approved, n8n loops through the unsold SKUs using batch processing and updates each product’s status through the Magento 2 REST API. A final summary email lands in your inbox so you have a clear record.
You can easily modify the “12 months” window to a different timeframe based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Scheduled Trigger
This workflow runs on a monthly schedule to review unsold products and request approval for deactivation.
- Add and open Scheduled Run Trigger.
- Set the schedule rule to run every month with Trigger At Hour set to
8. - Ensure the output connects to Compute Date 12 Months Back.
Step 2: Connect Magento Order and Product Retrieval
These nodes fetch orders from the past year and the complete product catalog for comparison.
- Open Retrieve Orders Past Year and set URL to
=https://magekwik.com/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=created_at&searchCriteria[filter_groups][0][filters][0][value]={{$json["sixMonthsAgo"]}} 00:00:00&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq&searchCriteria[pageSize]=0. - Set Authentication to
genericCredentialTypeand Generic Auth Type tohttpBearerAuth. - Open Retrieve All Product SKUs and set URL to
=https://magekwik.com/rest/V1/products?searchCriteria[pageSize]=0with the same bearer authentication settings.
Credential Required: Connect your httpBearerAuth credentials in both Retrieve Orders Past Year and Retrieve All Product SKUs.
Step 3: Set Up Date Calculation and SKU Processing
The workflow calculates the lookback date, extracts sold SKUs, and filters for unsold products. Multiple code nodes are used for this logic—configure them as provided.
- In Compute Date 12 Months Back, keep the JavaScript Code that sets
sixMonthsAgousingdate.setMonth(date.getMonth() - 12). - In Check Items Present, set the condition Left Value to
={{ $json.items.length }}with the boolean check totrue. - In Derive Sold SKU List, keep the provided JavaScript that builds
soldSkusfrom order items. - In Filter Unsold Products, keep the JavaScript that compares the product list to Derive Sold SKU List using
$('Derive Sold SKU List').first().json.soldSkus.
Filter Unsold Products outputs to both Combine Branch Data and Compose Approval Email in parallel.
Step 4: Configure Approval Email and Decision Logic
This branch builds the approval email, sends it for review, and checks the approval response before continuing.
- In Compose Approval Email, keep the HTML table generation JavaScript for
htmlBodyandcount. - Open Send Approval Email and set Send To to
[YOUR_EMAIL]. - Set Subject to
=Approve disabling {{ $json.count }} unsold productsand Message to the provided template containing{{ $json.htmlBody }}. - Ensure Operation is set to
sendAndWaitto collect the approval response. - In Approval Decision Check, set Left Value to
={{ $json.data.approved }}with the boolean check totrue.
Credential Required: Connect your Gmail credentials in Send Approval Email.
Step 5: Configure Deactivation Pipeline and Reporting
Approved items are expanded, processed in batches, deactivated via API, aggregated, and reported via email.
- In Combine Branch Data, set Mode to
chooseBranchand Use Data Of Input to2. - In Expand Unsold List, set Field To Split Out to
unsold. - In Iterate Item Batches, keep Reset set to
falseso batch looping continues. - In Deactivate Products, set URL to
=https://magekwik.com/rest/default/V1/products/{{ $json.sku }}, Method toPUT, and JSON Body to the provided status payload. - In Aggregate Product Data, set Aggregate to
aggregateAllItemDataand Fields To Include tosku,name,price,status. - In Assemble Report Email, keep the HTML table JavaScript and ensure it outputs
htmlBodyandcount. - In Notify Deactivation Email, set Send To to
[YOUR_EMAIL], Subject to={{ $json.count }} products have been deactivated, and Message to=The following {{ $json.count }} products have been disabled.\n\n{{ $json.htmlBody }}.
Credential Required: Connect your httpBearerAuth credentials in Deactivate Products.
Credential Required: Connect your Gmail credentials in Notify Deactivation Email.
Step 6: Test and Activate Your Workflow
Run a manual test to verify API responses, email approvals, and deactivation behavior before enabling the schedule.
- Click Execute Workflow to run the workflow manually from Scheduled Run Trigger.
- Confirm that Send Approval Email delivers the approval email and that approving it triggers Approval Decision Check to pass.
- Verify that Deactivate Products receives items in batches and returns successful responses.
- Check that Notify Deactivation Email sends a report containing a table of deactivated products.
- Once confirmed, toggle the workflow to Active to enable monthly automation.
Troubleshooting Tips
- Magento 2 credentials can expire or need specific permissions. If things break, check the Magento Admin integration token and API role permissions first.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Quick Answers
About 30 minutes if your Magento token and Gmail are ready.
No. You’ll mostly connect accounts and paste your Magento 2 API token. The workflow’s logic is already built, so it’s configuration and testing, not development.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in any email sending limits on your Gmail/Google Workspace account.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you probably should. You can change the “12 months ago” logic in the date calculation code, update the email recipient in the Gmail approval node, and swap “disable” for a different lifecycle action by adjusting the Magento update request. Common tweaks include using a 6-month window, excluding certain attribute sets or categories, and sending approvals to a shared operations inbox.
Most of the time it’s an invalid or expired Bearer token, so generate a new one and update the credential used by the HTTP Request nodes. If the token is fine, check that the integration role can read orders and update products. Another common culprit is the base URL being slightly wrong (missing store view path, wrong domain, http vs https), which makes the API look “down” when it isn’t.
Quite a lot, because it uses batching for large product sets. On n8n Cloud, your practical limit is the plan’s monthly executions, while self-hosting is mainly constrained by your server resources and Magento API responsiveness. For many small-to-mid stores, processing a few thousand products in a monthly run is normal. If you have a very large catalog, keep the batch size modest so Magento doesn’t throttle you.
Often, yes. This kind of workflow needs conditional checks, batching, and multi-step branching (including a human approval gate), and n8n handles that without turning every “extra path” into a cost surprise. You also get a solid self-hosting option, which is handy when you want predictable runs each month. Zapier or Make can still work if your store is small and you’re only doing lightweight notifications, not catalog updates. If you’re unsure, Talk to an automation expert and get a quick recommendation based on your catalog size.
Once this is running, catalog cleanup stops being a dreaded project and becomes a quick monthly decision. The workflow handles the repetitive work so you can focus on what actually sells.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.