Product snapshots
The product snapshot task records each product’s price and stock once per day. Without snapshots, the only data the plugin can show for those columns is the current value applied to historical orders — which makes margin trends and price/stock history invisible.
Snapshots feed three things:
- The Margins report — cost % over time, deteriorating margins, cost pressure
- The Product drill-down — historical price and stock series next to the sales timeline
- The Product snapshots browser — read-only view of the captured rows
How it works
Section titled “How it works”A scheduled task runs once per day (typically off-peak) and inserts one row per product into the p2lab_stats_product_snapshot table. Each row captures:
- Product ID + variant ID
- Captured at (timestamp)
- Selling price (currency configurable)
- Purchase price
- Stock
- Available stock (after open-order reservations)
The task is idempotent per day — running it twice on the same day doesn’t create duplicates.
Configuration
Section titled “Configuration”Settings live under Settings → Plugins → P2Lab Stats → Tasks → Snapshots.
| Setting | What it controls |
|---|---|
| Enabled | Toggle the daily task |
| Retention (days) | How long snapshots are kept before old rows are purged |
| Export progress retention | How long completed exports stay visible (covered in Export) |
Recommended retention: 365 days for stores that want year-over-year margin comparison. If table size becomes a concern, lower to 180 or 90 days.
Browsing snapshots
Section titled “Browsing snapshots”Open P2Lab Stats → Product snapshots to inspect the captured rows directly. Useful for:
- Verifying that the task is running (most recent capture date)
- Debugging unexpected margin trends (compare two consecutive days)
- Auditing a price change across all variants
The page shows the standard sortable data grid with filters by product, variant and date.