PHP code example of tmonier / sylius-b2b-predictive-analytics-plugin
1. Go to this page and download the library: Download tmonier/sylius-b2b-predictive-analytics-plugin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tmonier / sylius-b2b-predictive-analytics-plugin example snippets
Tmonier\SyliusPredictiveAnalyticsPlugin\TmonierSyliusPredictiveAnalyticsPlugin::class => ['all' => true],
use Tmonier\SyliusPredictiveAnalyticsPlugin\Calculator\PredictiveReorderCalculatorInterface;
$prediction = $calculator->calculate($variant, $company);
if ($prediction->isPredicted()) {
echo $prediction->explanation; // "ordered 5 times, every 28 days on median"
echo $prediction->expectedReorderDate->format('Y-m-d'); // Expected next reorder date
} else {
echo $prediction->explanation; // "insufficient history: ordered 1 time, 3 orders needed"
}
bash
php bin/console doctrine:migrations:migrate
bash
php bin/console tmonier:predictive:recalculate