Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass multiple marketplaceIds ? #30

Open
developer-gurpreet opened this issue Jul 30, 2019 · 1 comment
Open

How to pass multiple marketplaceIds ? #30

developer-gurpreet opened this issue Jul 30, 2019 · 1 comment

Comments

@developer-gurpreet
Copy link

Im getting .com orders successfully but I would like to access .ca orders as well,
I checked "https://github.com/sonnenglas/amazon-mws-laravel/blob/stable/src/AmazonOrderList.php"
but there you passed only $this->options['MarketplaceId.Id.1'] = $store[$s]['marketplaceId']; into constructor. my question is how we can pass multiple marketplaceIds?

@Dhavalptel
Copy link

@Gurpreet68 You can create an array in your config file

        'US' => [
			'merchantId'       => env('mwsMerchantId'),
			'marketplaceId'    => env('mwsMarketplaceId_US'),
			'keyId'            => env('mwsKeyId'),
			'secretKey'        => env('mwsSecretKey'),
			'mwsAuthToken'     => env('mwsAuthToken'),
			'amazonServiceUrl' => env('mwsAmazonServiceUrl_US'),
			'muteLog'          => env('mwsMuteLog', false),
		],
        'CA' => [
			'merchantId'       => env('mwsMerchantId'),
			'marketplaceId'    => env('mwsMarketplaceId_CA'),
			'keyId'            => env('mwsKeyId'),
			'secretKey'        => env('mwsSecretKey'),
			'mwsAuthToken'     => env('mwsAuthToken'),
			'amazonServiceUrl' => env('mwsAmazonServiceUrl_CA'),
			'muteLog'          => env('mwsMuteLog', false),
		],
        'UK' => [
			'merchantId'       => env('mwsMerchantId'),
			'marketplaceId'    => env('mwsMarketplaceId_UK'),
			'keyId'            => env('mwsKeyId'),
			'secretKey'        => env('mwsSecretKey'),
			'mwsAuthToken'     => env('mwsAuthToken'),
			'amazonServiceUrl' => env('mwsAmazonServiceUrl_UK'),
			'muteLog'          => env('mwsMuteLog', false),
		],

and from your controller use the foreach loop

        $stores = config('amazon-mws.store');
        foreach ($stores as $key => $store){
            $orders = new AmazonOrderList($key);
            $orders->setLimits('Created', "- 30 days");
            $channel = ($key == 'US') ? 'MFN' : 'AFN';
            $orders->setFulfillmentChannelFilter($channel);
            $filter = ($key == 'US') ? ["Unshipped", "PartiallyShipped", "Unfulfillable"] : ["Shipped","Unshipped", "PartiallyShipped", "Unfulfillable"];
            $orders->setOrderStatusFilter($filter);
            $orders->setUseToken();
            $orders->fetchOrders();
            $amazonOrders[] = $orders->getList();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants