How to modify the supplier.code address format

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!
User avatar
switch-cheehau
Posts: 14
Joined: 23 Jun 2021, 02:39

How to modify the supplier.code address format

Post by switch-cheehau » 02 Jul 2021, 14:01

Hi Aimeos,

How do i change the address format of supplier?
aimeos/aimeos-core/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php

Code: Select all

$this->feConfig['supplier.code']['short'][$addrId] = trim( preg_replace( "/\n+/m", "\n", sprintf(
	/// Supplier address format with label (%1$s), company (%2$s),
	/// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information),
	/// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s),
	/// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s)
	$context->getI18n()->dt( 'mshop', '%1$s, %2$s, %3$s %4$s, %6$s %7$s' ),
	$item->getLabel(),
	$addr->getCompany(),
	$addr->getAddress1(),
	$addr->getAddress2(),
	$addr->getAddress3(),
	$addr->getPostal(),
	$addr->getCity(),
	$addr->getState(),
	$addr->getCountryId(),
	$addr->getEmail(),
	$addr->getTelephone(),
	$addr->getTelefax(),
	$addr->getWebsite()
) ) );

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

Re: How to modify the supplier.code address format

Post by aimeos » 04 Jul 2021, 05:50

Currently, you have to extend the class and overwrite the method. A better option would be to add

Code: Select all

$this->getContext()->i18n()->dt( 'mshop', '%1$s ...' )
to enable translation for the address just like in the HTML clients.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
switch-cheehau
Posts: 14
Joined: 23 Jun 2021, 02:39

Re: How to modify the supplier.code address format

Post by switch-cheehau » 04 Jul 2021, 09:54

Thanks for the reply,

Can you give me more clue how to extend that particular class? Sorry i'm still learning how to do it.

Do i have to put something in my own extention config/mshop.php

Code: Select all

return [
    'service' => [
        'provider' => [
            'decorator' => [
                'local' => ['Supplier']
            ]
        ]
    ],
];

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

Re: How to modify the supplier.code address format

Post by aimeos » 04 Jul 2021, 14:01

Just use standard PHP "extends" syntax:

Code: Select all

namespace Aimeos\MShop\Service\Provider\Decorator;

class MySupplier extends Supplier
{
	public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider,
		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Service\Item\Iface $serviceItem )
	{
		parent::__construct( $provider, $context, $serviceItem );
		// ...
	}
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

Re: How to modify the supplier.code address format

Post by aimeos » 04 Jul 2021, 14:02

You can also create a PR for the Aimeos core, which is much less code to write. We will integrate it into 2021.04 too.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply