justbetter/laravel-magento-customer-prices

Package to push customer specific prices to Magento

2.1.1 2024-04-22 07:49 UTC

This package is auto-updated.

Last update: 2024-04-22 07:50:21 UTC


README

Package banner

Laravel Magento Customer Prices

Tests Coverage Analysis Total downloads

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:

  1. Makes sure all tests are passed
  2. Checks for any issues using static code analysis
  3. 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.

Package footer