How to get distribution center address in the checkout delivery page?

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
shainanand
Posts: 26
Joined: 16 Oct 2023, 15:05

How to get distribution center address in the checkout delivery page?

Post by shainanand » 22 Oct 2023, 07:13

I am trying to get the distribution center address in the checkout delivery page. Using the address postal, I want to call Fedex API to get rates. But I am not sure which is the right way to get supplier address?

Also, if have multiple products in card belonging to multiple sellers, how can I get the address for each of the seller?

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: How to get distribution center address in the checkout delivery page?

Post by aimeos » 23 Oct 2023, 08:30

You need to retrieve the products with the supplier and address information:

Code: Select all

$prodIds = $basket->getProducts()->getProductId();
$manager = \Aimeos\MShop::create( $this->context(), 'product' );
$filter = $manager->filter()->add( 'product.id', '==', $prodIds )->slice( 0, count( $prodIds ) );
$products = $manager->search( $filter, ['supplier', 'supplier/address'] );

foreach( $basket->getProducts() as $orderProduct )
{
	if( $product = $products->get( $orderProduct->getProductId() ) )
	{
		if( $supplier = $product->getRefItems( 'supplier' )->first() ) {
			$addrItem = $supplier->getAddressItems()->first();
		}
	}
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply