Download the PHP package tmonier/sylius-b2b-predictive-analytics-plugin without Composer
On this page you can find all versions of the php package tmonier/sylius-b2b-predictive-analytics-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tmonier/sylius-b2b-predictive-analytics-plugin
More information about tmonier/sylius-b2b-predictive-analytics-plugin
Files in tmonier/sylius-b2b-predictive-analytics-plugin
Package sylius-b2b-predictive-analytics-plugin
Short Description Predictive reorder analytics for Sylius 2 B2B: median interval calculation between successive orders per company and product, scheduled recalculation, reorder alerts
License MIT
Informations about the package sylius-b2b-predictive-analytics-plugin
Sylius B2B Predictive Analytics Plugin
Français : README.fr.md
Predictive reorder analytics for Sylius 2 B2B: calculates reorder patterns per company and product reference to anticipate purchase needs before stock runs out.
Built on tmonier/sylius-company-accounts-plugin (companies, members, roles) and tmonier/sylius-company-insights-plugin (purchasing dashboard).
What it does
- Median interval calculation: analyzes order history to determine the typical purchase rhythm for each product reference per company
- Explainable prediction: keeps the calculation explanation ("ordered 5 times, every 28 days on median")
- Expected reorder date: estimates the next order date based on usual rhythm
- Reorder alerts in customer account: displays a "To reorder soon" block for products with expected reorder date within the next 7 days (including overdue items up to one median interval)
- Pre-fill cart: "Prepare cart" button adds the typical median quantity to cart
- Dismiss alerts: "Not now" (temporary) or "Don't suggest again" (permanent) buttons
- Recalculation command: updates all predictions with a schedulable command
Prerequisites
- PHP 8.2 or higher
- Sylius 2.2.9 or 2.3+
tmonier/sylius-company-accounts-plugin^1.1 installedtmonier/sylius-company-insights-plugin^0.2 installed
Installation
-
Enable the plugin in
config/bundles.php: -
Run migrations to create the predictions table:
- Import the routes in
config/routes.yaml:
Usage
Reorder alerts in customer account
The plugin automatically displays a "To reorder soon" block in the customer area for product references with expected reorder date within the next 7 days (including overdue items up to one median interval).
Each alert offers:
- "Prepare cart" button that pre-fills the cart with the usual median quantity
- "Not now" button to temporarily hide the alert
- "Don't suggest again" button to permanently hide this product
Company isolation is strict: a buyer only sees alerts from their own company.
Calculate a prediction
Scheduled recalculation
The plugin includes a command to recalculate all predictions:
This command can be scheduled daily via cron:
Screenshots
The "Reorder soon" block of the customer account, in the Sylius B2B demo:
Calculation rules
- Minimum 3 orders: a prediction requires at least 3 completed orders
- Counted orders: only completed and non-cancelled orders are taken into account
- Robust median: the median is not skewed by extreme values, unlike the average
- Company isolation: each company has its own predictions, with no mixing
B2B demo
This plugin is used in the Sylius B2B demo: a Sylius 2.3 shop with fictitious sample data where the B2B plugins work together. The source code, setup and fixtures of the demo are in that repository.
- Online demo: sylius-b2b.thibaut-monier.fr
- Author: Thibaut Monier
The demo is an example, not a production setup.
License
MIT
All versions of sylius-b2b-predictive-analytics-plugin with dependencies
sylius/sylius Version ^2.2.9 || ^2.3
tmonier/sylius-company-accounts-plugin Version ^1.1
tmonier/sylius-company-insights-plugin Version ^0.2
twig/intl-extra Version ^3.21