caponica / amazon-mws-bundle
Symfony2 service wrapper for Amazon MWS PHP API
Installs: 959
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 1
Language:Twig
Type:symfony-bundle
Requires
- php: >=5.3.2
- caponica/amazon-mws-complete: ~1.0
- symfony/symfony: >=2.1.x-dev
This package is auto-updated.
Last update: 2024-11-29 04:52:16 UTC
README
Amazon MWS integration via a Symfony service.
Installation
Install using composer by adding the following in the require
section of your composer.json
file:
"require": { ... "caponica/amazon-mws-bundle": "dev-master" },
Register the bundle in your kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Caponica\AmazonMwsBundle\CaponicaAmazonMwsBundle(), ); }
Configuration
The bundle does not add a service to your project by default. To add the service, you will need to define the parameters and then the service itself.
To access multiple marketplaces, create multiple services (one for each marketplace). The simplest way to do this is with parameters (as shown below), but you can use any method you like to load the relevant configuration parameters and pass them to setConfig.
# app/config/parameters.yml caponica_amazon_mws_config_de: seller_id: your_seller_id_de access_key: your_access_key_de secret_key: your_secret_key_de application_name: your_app_name application_version: 1.0 amazon_site: DE caponica_amazon_mws_config_uk: seller_id: your_seller_id_uk access_key: your_access_key_uk secret_key: your_secret_key_uk application_name: your_app_name application_version: your_app_version amazon_site: UK
# services.yml caponica_mws_client_pool_de: class: %caponica_amazon_mws.client_pool.class% calls: - [ setConfig, [ %caponica_amazon_mws_config_de% ]] arguments: - '@your_logger' # optional Logger, see caponica/amazon-mws-complete docs caponica_mws_client_pool_uk: class: %caponica_amazon_mws.client.class% calls: - [ setConfig, [ %caponica_amazon_mws_config_uk% ]]
Often multiple marketplaces in the same region will share a single configuration. In these cases you can use the
siteCode
configuration parameter to re-use the same configuration:
# app/config/parameters.yml caponica_amazon_mws_config_europe: seller_id: your_seller_id_europe access_key: your_access_key_europe secret_key: your_secret_key_europe application_name: your_app_name application_version: 1.0 amazon_site: DE # just set one valid site here
# services.yml caponica_mws_client_pool_de: class: %caponica_amazon_mws.client_pool.class% calls: - [ setConfig, [ %caponica_amazon_mws_config_europe%, 'DE' ]] caponica_mws_client_pool_uk: class: %caponica_amazon_mws.client.class% calls: - [ setConfig, [ %caponica_amazon_mws_config_europe%, 'UK' ]]
Usage
To access the service, just reference it by the service name you defined above. E.g., from a controller:
/** @var CaponicaAmazonMwsComplete\ClientPool\MwsClientPool $mwsClientPoolUk */
$mwsClientPoolUk = $this->container->get('caponica_mws_client_pool_uk');
$mwsProductClientPackUk = $mwsClientPoolUk->getProductClientPack();