justbetter / laravel-magento-customer-prices
Package to push customer specific prices to Magento
Installs: 4 042
Dependents: 1
Suggesters: 0
Security: 0
Stars: 14
Watchers: 4
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.1
- brick/money: ^0.7|^0.8
- justbetter/laravel-error-logger: ^2.3
- justbetter/laravel-magento-client: ^2.4
- justbetter/laravel-magento-products: ^1.4
- laravel/framework: ^10.0|^11.0
- spatie/laravel-activitylog: ^4.8
Requires (Dev)
- doctrine/dbal: ^3.4
- larastan/larastan: ^2.9
- laravel/pint: ^1.15
- orchestra/testbench: ^8.0|^9.0
- phpstan/phpstan-mockery: ^1.1
- phpunit/phpunit: ^10.0
README
Laravel Magento Customer Prices
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.
Features
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!
Installation
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
Laravel Nova
We have a Laravel Nova integration for this package.
Usage
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(); }
Retrieving Customer Prices
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:
retrieve(string $sku)
Must return an enumerable of \JustBetter\MagentoCustomerPrices\Data\CustomerPriceData
objects
retrieveAllSkus()
Must return an enumerable of strings
retrieveUpdatedSkus()
Must return an enumerable of strings
Example
See the \JustBetter\MagentoCustomerPrices\Retriever\DummyCustomerPriceRetriever
class for an example.
Magento 2 Customer Prices
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);
Quality
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
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.