Installation Add the package via Composer:
composer require aliznet/akeneo-websphere-connector
Note: Ensure your Laravel project meets the PHP 5.4+ requirement (though Laravel 5+ typically uses PHP 7.4+; verify compatibility).
Configuration
Locate the config/akeneo_websphere.php file (auto-generated or manually created). Configure:
'websphere' => [
'host' => env('WEBSPHERE_HOST', 'localhost'),
'port' => env('WEBSPHERE_PORT', 80),
'username' => env('WEBSPHERE_USERNAME', 'admin'),
'password' => env('WEBSPHERE_PASSWORD', ''),
'timeout' => 30,
],
Publish the config if needed:
php artisan vendor:publish --provider="Aliznet\AkeneoWebsphereConnector\AkeneoWebsphereConnectorServiceProvider"
First Use Case: Sync Product Data Use the connector to fetch a product from Websphere Commerce (WCS) and map it to Akeneo PIM:
use Aliznet\AkeneoWebsphereConnector\Services\WebsphereConnector;
$connector = app(WebsphereConnector::class);
$product = $connector->getProductById('12345');
// Transform and save to Akeneo (custom logic required)
Fetch Products Retrieve products from WCS in batches:
$products = $connector->getProducts(['limit' => 50, 'offset' => 0]);
Transform Data Use Laravel’s service container to bind a custom transformer:
$this->app->bind(WcsToAkeneoTransformer::class, function ($app) {
return new WcsToAkeneoTransformer($app->make(WebsphereConnector::class));
});
Example transformer:
class WcsToAkeneoTransformer {
public function transform(array $wcsProduct): array {
return [
'sku' => $wcsProduct['sku'],
'family' => 'electronics',
'attributes' => [
'name' => $wcsProduct['name'],
'price' => $wcsProduct['price']['value'],
],
];
}
}
Queue Sync Jobs
Offload sync to a queue (e.g., sync-wcs-products job):
SyncWcsProducts::dispatch($products)->onQueue('akeneo');
Akeneo API Client
Use akeneo/pim-community-dev to push transformed data:
$akeneoClient = new AkeneoClient([
'client_id' => env('AKENEO_CLIENT_ID'),
'secret' => env('AKENEO_SECRET'),
'endpoint' => env('AKENEO_ENDPOINT'),
]);
$akeneoClient->createProduct($transformedProduct);
Event-Driven Sync
Trigger syncs via Akeneo events (e.g., ProductCreatedEvent):
AkeneoProductCreated::dispatch($akeneoProduct)
->then(function () {
SyncWcsProduct::dispatch($akeneoProduct->getSku());
});
Laravel Scheduler
Schedule daily syncs in app/Console/Kernel.php:
$schedule->job(new SyncWcsProducts)->daily();
Deprecated Symfony 2.7 The package requires Symfony 2.7, which may conflict with Laravel’s modern stack. Test thoroughly or fork the package to update dependencies.
No Laravel-Specific Features The package lacks Laravel-specific helpers (e.g., Eloquent models, queues). Expect to build abstractions.
Authentication Quirks WCS may require SOAP headers or tokens. Extend the connector:
$connector->setAuthHeader('X-Auth-Token', env('WCS_TOKEN'));
Rate Limiting WCS APIs often throttle requests. Implement exponential backoff in your sync logic:
try {
$response = $connector->getProducts();
} catch (RateLimitException $e) {
sleep($e->getRetryAfter());
retry();
}
Enable Verbose Logging
Configure Monolog in config/logging.php to log WCS requests:
'channels' => [
'websphere' => [
'driver' => 'single',
'path' => storage_path('logs/websphere.log'),
'level' => 'debug',
],
],
Then log requests in the connector:
\Log::channel('websphere')->debug('WCS Request:', ['data' => $requestData]);
Mock WCS for Testing Use Laravel’s HTTP client to mock responses:
$this->partialMock(WebsphereConnector::class, function ($mock) {
$mock->shouldReceive('getProductById')
->andReturn(['sku' => 'test', 'name' => 'Test Product']);
});
Custom Endpoints Extend the connector to support non-standard WCS endpoints:
class CustomWebsphereConnector extends WebsphereConnector {
public function getInventory($storeId) {
return $this->callSoapMethod('getInventory', ['storeId' => $storeId]);
}
}
Webhook Listeners
Listen for WCS webhook events (e.g., ProductUpdated) and trigger Akeneo syncs:
use Aliznet\AkeneoWebsphereConnector\Events\WcsProductUpdated;
WcsProductUpdated::listen(function ($event) {
SyncWcsProduct::dispatch($event->getSku());
});
Caching Cache WCS responses to reduce API calls:
$products = Cache::remember("wcs_products_{$offset}", now()->addHours(1), function () use ($connector, $offset) {
return $connector->getProducts(['offset' => $offset]);
});
How can I help you explore Laravel packages today?