agencednd/oro-api-connector-bundle
Installation:
composer require agencednd/oro-api-connector-bundle
Ensure your project uses OroCommerce Community Edition v1.x.
Enable Bundle: The bundle auto-enables after installation.
Regenerate API Docs: Clear the API documentation cache to expose new endpoints:
php app/console oro:api:doc:cache:clear -e prod
Expose WSSE Script: Copy the authentication script to your web directory:
cp -R vendor/agencednd/oro-api-connector-bundle/Resources/public/scripts/ web/scripts
Update web/scripts/generate-wsse-header.php with your OroCommerce API key (found in oroUrl/admin/user/profile/view).
This bundle bridges OroCommerce’s REST API with Amazon Alexa via AWS Lambda. Follow these steps to enable voice commands for e-commerce actions:
Protect the WSSE Script:
.htpasswd entry (e.g., user:passwd) using htpasswd tools.web/scripts/.htaccess to point to the .htpasswd file:
AuthUserFile /srv/www/orocommerce/web/scripts/.htpasswd
Deploy AWS Lambda:
index.js and intents.json (from vendor/agencednd/oro-api-connector-bundle/Resources/public/alexa/).oroHost (Line 23) with your OroCommerce domain.auth credentials (Line 28) with the .htpasswd user:pass.Test Alexa Skill: Configure your Alexa skill to trigger the Lambda function. Example intent:
"Alexa, ask [YourSkill] to check my cart total."
/api/alexa/orders) to fetch data for Alexa responses.generate-wsse-header.php.
// Example AWS Lambda call to OroCommerce API
const wsseHeader = await getWsseHeader(); // Calls generate-wsse-header.php
const response = await fetch(`${oroHost}/api/rest/v1/orders`, {
headers: { 'Authorization': wsseHeader }
});
GetCartTotalIntent) to OroCommerce API endpoints.
// Example intents.json snippet
{
"intents": [
{
"intent": "GetCartTotalIntent",
"slots": [],
"apiEndpoint": "/api/rest/v1/orders/summary"
}
]
}
// index.js snippet
const cartTotal = response.data.total;
const speechOutput = `<speak>Your cart total is ${cartTotal} ${currency}.</speak>`;
order.placed) to trigger Alexa notifications.oroUrl/admin/user/profile/view if the script fails. Avoid hardcoding keys in Lambda.config.yml allows requests from your Alexa domain:
oro_api:
api:
enabled: true
cors_origins:
- 'https://your-alexa-skill-domain.com'
oroHost and .htpasswd credentials as Lambda environment variables (not in code).
const oroHost = process.env.ORO_HOST;
const auth = process.env.ALEXA_AUTH;
console.error('OroCommerce API Error:', error);
generate-wsse-header.php locally for testing:
ngrok http 80 --host-header=localhost
Update Lambda’s oroHost to your ngrok URL (e.g., https://abc123.ngrok.io).WSSE Deprecation:
Script Path Hardcoding:
generate-wsse-header.php script assumes it’s in web/scripts/. If moved, update .htaccess and Lambda calls accordingly.API Rate Limiting:
const retry = require('async-retry');
await retry(async () => {
const response = await fetch(oroHost, { headers: { Authorization: wsseHeader } });
if (response.status === 429) throw new Error('Rate limited');
return response.json();
}, { retries: 3 });
HTTPS Requirements:
WSSE Header Issues:
curl -X GET http://your-orocommerce/web/scripts/generate-wsse-header.php
WSSE realm="OroCommerce", profile="UsernameToken", type="AppSpecific", created="1234567890", nonce="abc123", username="api_user", passwordDigest="hashed_password"
Lambda Logs:
401 Unauthorized: Invalid WSSE header or API key.404 Not Found: Incorrect API endpoint or missing route.OroCommerce Logs:
app/config/config.yml:
oro_api:
api:
enabled: true
debug: true
var/log/dev.log for API request details.Custom API Endpoints:
AgenceDnD\OroApiConnectorBundle\Controller./api/alexa/products endpoint to fetch product recommendations.Intent Expansion:
intents.json and update index.js to handle them:
{
"intent": "AddToCartIntent",
"slots": [
{ "name": "productId", "type": "AMAZON_NUMBER" }
],
"apiEndpoint": "/api/rest/v1/cart/items"
}
OAuth2 Migration:
const token = await getOAuthToken(); // New endpoint
const response = await fetch(oroHost, { headers: { Authorization: `Bearer ${token}` } });
Multi-Currency Support:
GetCartTotalIntent to convert amounts to a default currency:
const currency = response.data.currency;
const convertedTotal = (cartTotal * exchangeRate).toFixed(2); // Requires exchangeRate API
How can I help you explore Laravel packages today?