PHP code example of justbetter / laravel-magento-customer-prices

1. Go to this page and download the library: Download justbetter/laravel-magento-customer-prices 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/ */

    

justbetter / laravel-magento-customer-prices example snippets




protected function schedule(Schedule $schedule): void
{
    $schedule->command(\JustBetter\MagentoCustomerPrices\Commands\ProcessCustomerPricesCommand::class)->everyMinute();

    // Retrieve all customer prices daily
    $schedule->command(\JustBetter\MagentoCustomerPrices\Commands\Retrieval\RetrieveAllCustomerPricesCommand::class)->daily();

    // Retrieve updated customer prices hourly
    $schedule->command(\JustBetter\MagentoCustomerPrices\Commands\Retriavel\RetrieveAllCustomerPricesCommand::class, ['from' => 'now - 1 hour'])->hourly();
}




namespace App\Integrations\MagentoCustomerPrices;

use JustBetter\MagentoCustomerPrices\Data\CustomerPriceData;
use JustBetter\MagentoCustomerPrices\Repository\Repository;

class MyCustomerPriceRepository extends Repository
{
  public function retrieve(string $sku): ?CustomerPriceData
    {
        return CustomerPriceData::of([
            'sku' => $sku,
            'prices' => [
                [
                    'customer_id' => 1,
                    'price' => 10,
                    'quantity' => 1,
                ],
                [
                    'customer_id' => 1,
                    'price' => 8,
                    'quantity' => 10,
                ],
            ],
        ]);
    }
}



namespace App\Integrations\MagentoCustomerPrices;

use JustBetter\MagentoCustomerPrices\Repositories\Repository;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;

class MyCustomerPriceRepository implements Repository
{
    public function skus(?Carbon $from = null): Collection
    {
        return collect(['sku_1', 'sku_2']);
    }
}

class BaseRepository
{
    // How many prices may be retrieved at once when the process job runs
    protected int $retrieveLimit = 250;

    // How many prices may be updated at once when the process job runs
    protected int $updateLimit = 250;

    // How many times an update to Magento may fail before it stops trying
    protected int $failLimit = 3;
}



return [
    'repository' => \App\Integrations\MagentoCustomerPrices\MyPriceRepository::class,
];

php artisan vendor:publish --provider="JustBetter\MagentoCustomerPrices\ServiceProvider" --tag="config"

php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"

php artisan migrate



app()->singleton(\JustBetter\MagentoCustomerPrices\Contracts\Update\UpdatesCustomerPrice::class, YourCustomUpdater::class);