How to modify the supplier.code address format
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- switch-cheehau
- Posts: 14
- Joined: 23 Jun 2021, 02:39
How to modify the supplier.code address format
Hi Aimeos,
How do i change the address format of supplier?
aimeos/aimeos-core/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php
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()
) ) );
Re: How to modify the supplier.code address format
Currently, you have to extend the class and overwrite the method. A better option would be to add
to enable translation for the address just like in the HTML clients.
Code: Select all
$this->getContext()->i18n()->dt( 'mshop', '%1$s ...' )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- switch-cheehau
- Posts: 14
- Joined: 23 Jun 2021, 02:39
Re: How to modify the supplier.code address format
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
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']
]
]
],
];
Re: How to modify the supplier.code address format
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, give us a star
If you like Aimeos, give us a star
Re: How to modify the supplier.code address format
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, give us a star
If you like Aimeos, give us a star