How to add additional fields to a customer

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!
mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: How to add additional fields to a customer

Post by mohal_04 » 11 Apr 2018, 12:18

aimeos wrote:You can find documentation about Vue.JS there: https://vuejs.org/
You don't need that much knowledge about Vue.JS. There are only three important things:

1.) Add the new key in your new template there:
https://github.com/aimeos/ai-admin-jqad ... rd.php#L11

2.) Copy the form line and replace "price.value" by your new key:
https://github.com/aimeos/ai-admin-jqad ... rd.php#L70

3.) Check if your new key/value is listed there (use the web inspector for example):
https://github.com/aimeos/ai-admin-jqad ... rd.php#L23
Hi,

So, what to do if point 3 fails? Where does "data-items=" get populated?

Thanks!

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: How to add additional fields to a customer

Post by tenkraD » 11 Apr 2018, 23:17

aimeos wrote:Your new value isn't set in the item there:
https://github.com/aimeos/ai-admin-jqad ... d.php#L357
-you have to add youre setter from item class there in fromArray "setMinimumAdvertisedPrice($this->getValue( $data, 'price.minimumadvertisedprice' . $idx, ' 0.00' ))" . This is where the data is populated.

and that this new file instead of the standard is recognized u have to add this configuration value
*thanks to nos3 user* https://aimeos.org/docs/Configuration/C ... price/name

See Extend Stock ==> post6012.html#p6012

bye tenkraD
Last edited by tenkraD on 12 Apr 2018, 08:13, edited 2 times in total.

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: How to add additional fields to a customer

Post by tenkraD » 11 Apr 2018, 23:27

aimeos wrote:Your new value isn't set in the item there:
https://github.com/aimeos/ai-admin-jqad ... d.php#L357
-you have to add youre setter from item class there in fromArray "setMinimumAdvertisedPrice($this->getValue( $data, 'price.minimumadvertisedprice' . $idx, ' 0.00' ))" . This is where the data is populated.

and that this new file instead of the standard is recognized u have to add this configuration value
*thanks to nos3 user* https://aimeos.org/docs/Configuration/C ... price/name

See Extend Stock ==> post6012.html#p6012

bye tenkraD
Last edited by tenkraD on 12 Apr 2018, 08:15, edited 1 time in total.

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

Re: How to add additional fields to a customer

Post by aimeos » 12 Apr 2018, 07:14

All modifications must be done in your own extension. Never change the Aimeos Core!
If you need to store additional data from the admin interface, you have to extend the existing class using a new name, overwrite the fromArray() method and configure your new class name like @tenkraD said.

The data for the template is populated there:
https://github.com/aimeos/ai-admin-jqad ... d.php#L420
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: How to add additional fields to a customer

Post by mohal_04 » 12 Apr 2018, 07:54

aimeos wrote:All modifications must be done in your own extension. Never change the Aimeos Core!
If you need to store additional data from the admin interface, you have to extend the existing class using a new name, overwrite the fromArray() method and configure your new class name like @tenkraD said.

The data for the template is populated there:
https://github.com/aimeos/ai-admin-jqad ... d.php#L420
Hi,

But I have to make changes in Standard.php file, otherwise, value of new field is not being saved.

Standard.php is in this directory:

./ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Product/Price/Standard.php

The fromArray() method of my extension (see below) doesn't save data.

./ext/10buckonly/lib/custom/src/MShop/Price/Manager/Custompricefields.php

Code: Select all

public function fromArray(array $list)
    {
        $unknown = [];
        $list = parent::fromArray($list);

        foreach ($list as $key => $value) {
            switch ($key) {
                case 'price.minimumadvertisedprice':
                    $this->setMinimumAdvertisedPrice($value);
                    break;
                case 'price.productioncost':
                    $this->setProductioncost($value);
                    break;
                default:
                    $unknown[$key] = $value;
            }
        }
        return $unknown;
    }
This thing has made me pull my hairs out.

Thanks!

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

Re: How to add additional fields to a customer

Post by aimeos » 12 Apr 2018, 08:03

No, it's the same as for the managers: You have to extend from the standard class and create e.g.

./ext/myextendsion/admin/jqadm/src/Admin/JQAdm/Product/Price/Mystandard.php

which contains:

Code: Select all

class MyStandard extends Standard
{
    protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
    {
        // your modified code
    }
}
and configure your new class using:

Code: Select all

admin/jqadm/product/price/name = Mystandard
e.g. for Laravel in config/shop.php:

Code: Select all

'admin' => [
    'jqadm' => [
        'product' => [
            'price' => [
                'name' => 'Mystandard'
            ]
        ]
    ]
]
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: How to add additional fields to a customer

Post by tenkraD » 12 Apr 2018, 08:04

No not here "./ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Product/Price/Standard.php"

See Extend Stock for a full working example ==> post6012.html#p6012

This should solve your problem. I done the same but with Stock Class instead of Price.

bye tenkraD

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: How to add additional fields to a customer

Post by mohal_04 » 12 Apr 2018, 08:19

aimeos wrote:All modifications must be done in your own extension. Never change the Aimeos Core!
If you need to store additional data from the admin interface, you have to extend the existing class using a new name, overwrite the fromArray() method and configure your new class name like @tenkraD said.

The data for the template is populated there:
https://github.com/aimeos/ai-admin-jqad ... d.php#L420
Hi,

The only way for me to save value of my new field is to add following two statements in fromArray() method of Standard class.

./ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Product/Price/Standard.php

Code: Select all

$priceItem->setMinimumadvertisedprice( $this->getValue( $data, 'price.minimumadvertisedprice/' . $idx, '0.00' ) );
$priceItem->setProductioncost( $this->getValue( $data, 'price.productioncost/' . $idx, '0.00' ) );
The fromArray() method in my extension is not saving value. :'( :'( :'( :'( :'(

Thanks!

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: How to add additional fields to a customer

Post by tenkraD » 12 Apr 2018, 08:47

C'mon mohal,

No not here "./ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Product/Price/Standard.php"

See Extend Stock for a full working example ==> post6012.html#p6012

This should solve your problem. I done the same but with Stock Class instead of Price.

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: How to add additional fields to a customer

Post by mohal_04 » 12 Apr 2018, 09:35

tenkraD wrote:C'mon mohal,

No not here "./ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Product/Price/Standard.php"

See Extend Stock for a full working example ==> post6012.html#p6012

This should solve your problem. I done the same but with Stock Class instead of Price.
Hi,

Thanks a lot buddy!!! Issue resolved!!! Blood Pressure dropping now!!! I hope this is the last complex issue that I faced. Thanks A LOT!!!

Thanks!

Post Reply