Add custom field to Customer profile

Help for integrating the Laravel package
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!
Sys32

Add custom field to Customer profile

Post by Sys32 » 12 Jan 2021, 14:33

Aimeos Package, directly from Composer.
PHP 7.3
Linux

I am running into some issues with my setup. Basically what I am attempting to do, is add a custom field to the database. However the layout is not at all like Laravel used to be, with Controllers etc. It probably follows a different standard. But I am not very familiar with this, and I have hit a wall.

1. I cannot seem to overwrite the templates. I already wrote in the HTML for the customers profile, which shows up correctly.

Code: Select all

<div class="col-sm-8">
	<input class="form-control item-agent" type="text" tabindex="1"
		name="<?= $enc->attr( $this->formparam( array( 'item', 'customer.agent_id' ) ) ); ?>"
		placeholder="<?= $enc->attr( $this->translate( 'admin', 'Agent ID' ) ); ?>"
		value="<?= $enc->attr( $this->get( 'itemData/customer.agent_id' ) ); ?>" />
</div>
2. The actual customer data does hold the Agent ID as in the database, when I die Dump inside ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Customer/standard.php @ get() using

Code: Select all

dd($view->item)
but I cannot get it to pass the ToArray function and to the view.

3. I attempted to add it to ai-laravel/lib/custom/config/mshop/customer.php under search, mysql.

Code: Select all

lvu."agent_id" AS "customer.agent_id"
but I got nothing from here.

4. I also added it to ai-laravel/lib/custom/src/MShop/Customer/Manager

Code: Select all

'customer.agent_id' => array(
	'label' => 'Agent ID',
	'code' => 'customer.agent_id',
	'internalcode' => 'lvu."agent_id"',
	'type' => 'integer',
	'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
	'public' => true,
),
I feel like the documentation could be alot better at this point. :/

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

Re: Add custom field to Customer profile

Post by aimeos » 13 Jan 2021, 09:22

Do you use a decorator to add the new field?
https://aimeos.org/docs/latest/infrastr ... -managers/
If yes, make sure you use version 2020.10.x because I remember there was a commit which extends toArray() automatically.

In case you extended the manager and item classes via "extends", make sure you've implemented the fromArray() and toArray() methods like described here:
https://aimeos.org/docs/latest/infrastr ... ers/#items
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply