retrieve custom customer property
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
retrieve custom customer property
Hi,
I added a custom property (for AccountNo) to my customers object.
How can I retriev and show the property value (account ID) in the customer profile view (/shop/profil)?
I havent found any examples. I tried but without success
thanks
I added a custom property (for AccountNo) to my customers object.
How can I retriev and show the property value (account ID) in the customer profile view (/shop/profil)?
I havent found any examples. I tried
Code: Select all
$this->getRefItems( 'customer', null, 'accountid' ) as $attrId => $attrItem ) : ?>
thanks
- Attachments
-
- customer property.PNG (30.76 KiB) Viewed 2280 times
Re: retrieve custom customer property
The getRefItems() method is only for resources referenced by the *_list tables like attributes, images, prices, products, texts, etc. For properties, please use getPropertyItems() or a related method:
https://github.com/aimeos/aimeos-core/b ... /Iface.php
https://github.com/aimeos/aimeos-core/b ... /Iface.php
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: retrieve custom customer property
thanks, but unfortunately i don't get it to work:
the first one (customer.company) works fine, but as soon as I add getPropertyItems( 'accountid', true ) I just receive "A non-recoverable error occured"
the first one (customer.company) works fine, but as soon as I add getPropertyItems( 'accountid', true ) I just receive "A non-recoverable error occured"
Code: Select all
<div class="form-item form-group row company">
company: <?= $enc->attr( $this->value( $addr, 'customer.company' ) ); ?>
</div>
<div class="form-item form-group row company">
Account-ID: <?php foreach( $this->getPropertyItems( 'accountid', true ) as $props ) : ?>
</div>
Re: retrieve custom customer property
"$this" refers to the view in the templates. You need the customer item (either it's already added by the component or you need to write a decorator that adds item to the view), then you can use getPropertyItems() on that object.
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: retrieve custom customer property
sorry, but I couldn't solve it and I couldn't find a similar forum post / question either.
Can you provde an example or any other hint how I can create this decorator please?
Goal: I'd like to show the customer porperty "AccountNo" on the users profile page (next to the adress details) and in the confirmation mail.
Can you provde an example or any other hint how I can create this decorator please?
Goal: I'd like to show the customer porperty "AccountNo" on the users profile page (next to the adress details) and in the confirmation mail.
Re: retrieve custom customer property
Here's the relevant code to see what is required:
https://github.com/aimeos/ai-client-htm ... #L363-L366
The customer item is assigned as "profileCustomerItem" to the view but doesn't have the properties by default, so:
1.) Add a configuration for "client/html/account/profile/domains" which contains ['customer/address', 'customer/property']
2.) In the account profile view, you can than use $this->profileCustomerItem->getProperties('accountno'), which returns an array
In the e-mail, things are a bit more complicated because there's not customer item available by default (the e-mail template only contains the data from the order itself). Thus, create a decorator, that fetches the customer item and assigns it to the e-mail view:
https://aimeos.org/docs/Developers/Html ... components
The customer ID is in the order base item and available with $baseItem->getCustomerId(). You can use it to fetch the customer item with the customer manager. Then, you can do the same as in the profile template.
The code for the decorator would be:
https://github.com/aimeos/ai-client-htm ... #L363-L366
The customer item is assigned as "profileCustomerItem" to the view but doesn't have the properties by default, so:
1.) Add a configuration for "client/html/account/profile/domains" which contains ['customer/address', 'customer/property']
2.) In the account profile view, you can than use $this->profileCustomerItem->getProperties('accountno'), which returns an array
In the e-mail, things are a bit more complicated because there's not customer item available by default (the e-mail template only contains the data from the order itself). Thus, create a decorator, that fetches the customer item and assigns it to the e-mail view:
https://aimeos.org/docs/Developers/Html ... components
The customer ID is in the order base item and available with $baseItem->getCustomerId(). You can use it to fetch the customer item with the customer manager. Then, you can do the same as in the profile template.
The code for the decorator would be:
Code: Select all
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expire = null )
{
$custid = $view->extOrderBaseItem->getCustomerId();
$manager = \Aimeos\MShop::create( $this->getContext(), 'customer' );
$view->customerItem = $manager->getItem( $custid, ['customer/property'] );
}
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