This package provides a way to add customer specific prices to Magento from a Laravel app. By default, it uses the JustBetter Magento 2 Customer Pricing module for customer specific prices. You can implement another customer specific price module, see Updating Customer Prices.
This package can:
- Retrieve prices from any source
- Push customer specific prices to Magento
- Only update prices in Magento when are modified. i.e. when you retrieve the same price ten times it only updates once to Magento
- Automatically stop syncing when updating fails
- Logs activities using Spatie activitylog
- Logs errors using JustBetter Error Logger
- Checks if Magento products exist using JustBetter Magento Products
Check out Laravel Magento Prices for connecting regular prices to Magneto We also have a Magento Client to easily connect Laravel to Magento!
Require this package: composer require justbetter/laravel-magento-customer-prices
Publish the config
php artisan vendor:publish --provider="JustBetter\MagentoCustomerPrices\ServiceProvider" --tag="config"
Publish the activity log's migrations:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
Run the migrations
php artisan migrate
We have a Laravel Nova integration for this package.
Add the following commands to your scheduler:
<?php
protected function schedule(Schedule $schedule): void
{
$schedule->command(\JustBetter\MagentoCustomerPrices\Commands\SyncCustomerPricesCommand::class)->everyMinute();
// Retrieve all customer prices weekly
$schedule->command(\JustBetter\MagentoCustomerPrices\Commands\RetrieveAllCustomerPricesCommand::class)->weekly();
// Retrieve updated customer prices daily
$schedule->command(\JustBetter\MagentoCustomerPrices\Commands\RetrieveUpdatedCustomerPricesCommand::class)->daily();
}
To retrieve prices you have to write a retriever.
A retriever is a class that extends the \JustBetter\MagentoCustomerPrices\Retriever\CustomerPriceRetriever
class.
You'll be required to write three methods:
Must return an enumerable of \JustBetter\MagentoCustomerPrices\Data\CustomerPriceData
objects
Must return an enumerable of strings
Must return an enumerable of strings
See the \JustBetter\MagentoCustomerPrices\Retriever\DummyCustomerPriceRetriever
class for an example.
By default this package uses the JustBetter Magento 2 Customer Pricing module for updating prices to Magento.
If you use another Magento 2 module for customer specific pricing you can write your own class that updates prices in Magento.
You can do this by implementing JustBetter\MagentoCustomerPrices\Contracts\UpdatesMagentoCustomerPrices
.
See \JustBetter\MagentoCustomerPrices\Actions\UpdateCustomerPrices
for an example.
Don't forget to bind your own class!
<?php
app()->singleton(UpdatesMagentoCustomerPrices::class, YourCustomUpdater::class);
To ensure the quality of this package, run the following command:
composer quality
This will execute three tasks:
- Makes sure all tests are passed
- Checks for any issues using static code analysis
- Checks if the code is correctly formatted
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.