Page 1 of 2

Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 06:03
by mohal_04
Hi,

I need help regarding product forms in Aimeos Administration panel. I want to add additional fields in the forms. Can anyone help me how I can do this?

Thanks!

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 07:30
by aimeos
This depends a bit on the information you want to store because either you need to extend the managers and templates or you can add a new subpart. Can you explain which information you want to store?

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 08:01
by mohal_04
aimeos wrote:This depends a bit on the information you want to store because either you need to extend the managers and templates or you can add a new subpart. Can you explain which information you want to store?
I wish to add new fields to product form, e.g. a latitude and longitude field, country of origin, and few other modifications to existing fields.

If this is documented somewhere then please, share those links. Specially about "managers, templates, and subparts." I am in a hurry.

Thanks a lot!!!

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 08:21
by aimeos
The easiest way is to use the product properties where you can add arbitrary information without extending the database or the managers/items. You can even provide a new subpart and template with specialized fields like the "Physical" subpanel to improve usability (weight, height, length and width are stored as product properties).

If you want the country of origin to be an option in the facetted search, you have to use attributes you associate to the products instead. Properties doesn't generate facetts.

For extending the admin interface there's no documentation yet. You have to have a look into the existing code to see how it works and copy/paste the things you need.

If you want to extend the database instead, you should read these articles:
Add tables and fields to the database: https://aimeos.org/docs/Developers#Database
Create or extend managers/items: https://aimeos.org/docs/Developers#Managers_and_items

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 10:04
by mohal_04
aimeos wrote:The easiest way is to use the product properties where you can add arbitrary information without extending the database or the managers/items. You can even provide a new subpart and template with specialized fields like the "Physical" subpanel to improve usability (weight, height, length and width are stored as product properties).

If you want the country of origin to be an option in the facetted search, you have to use attributes you associate to the products instead. Properties doesn't generate facetts.

For extending the admin interface there's no documentation yet. You have to have a look into the existing code to see how it works and copy/paste the things you need.

If you want to extend the database instead, you should read these articles:
Add tables and fields to the database: https://aimeos.org/docs/Developers#Database
Create or extend managers/items: https://aimeos.org/docs/Developers#Managers_and_items
Hi,

Where should I copy/paste the part of code? Obviously, I am using Laravel 5.6 so I have to do modifications according to Laravel 5.6. But the core Aimeos is not in Laravel.

Please, help!

Thanks!

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 27 Mar 2018, 10:19
by mohal_04
aimeos wrote:The easiest way is to use the product properties where you can add arbitrary information without extending the database or the managers/items. You can even provide a new subpart and template with specialized fields like the "Physical" subpanel to improve usability (weight, height, length and width are stored as product properties).

If you want the country of origin to be an option in the facetted search, you have to use attributes you associate to the products instead. Properties doesn't generate facetts.

For extending the admin interface there's no documentation yet. You have to have a look into the existing code to see how it works and copy/paste the things you need.

If you want to extend the database instead, you should read these articles:
Add tables and fields to the database: https://aimeos.org/docs/Developers#Database
Create or extend managers/items: https://aimeos.org/docs/Developers#Managers_and_items
And is there any section from where I can add Manufacturers?

Thanks!

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 28 Mar 2018, 08:02
by aimeos
If you create a new subpanel for the admin interface, it has to be in the same directory structure as in the ./ext/ai-admin-jqadm/admin/jqadm/src/ folder of your own Aimeos extension.

Manufacturers (called suppliers in Aimeos) have their own panel in the admin interface. There you can also associate products to them.

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 30 Mar 2018, 11:56
by mohal_04
aimeos wrote:If you create a new subpanel for the admin interface, it has to be in the same directory structure as in the ./ext/ai-admin-jqadm/admin/jqadm/src/ folder of your own Aimeos extension.

Manufacturers (called suppliers in Aimeos) have their own panel in the admin interface. There you can also associate products to them.
What if I only want to add a new field in Product form in Admin Panel? I have followed all steps mentioned in following link: https://aimeos.org/docs/Developers/Libr ... gers_items

But new field value is not being saved. I am sure I am missing something. In your above comment you said to add code in ./ext/ai-admin-jqadm/admin/jqadm/src/ folder but in the link the writer asks to create class in this directory: ./<yourext>/lib/custom/src/MShop/Product/Item/Myproject.php

Please, help!

Thanks!

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 31 Mar 2018, 17:18
by aimeos
mohal_04 wrote: What if I only want to add a new field in Product form in Admin Panel? I have followed all steps mentioned in following link: https://aimeos.org/docs/Developers/Libr ... gers_items
Yes, you have to follows the steps in that article and create an extended item and manager.
mohal_04 wrote: But new field value is not being saved. I am sure I am missing something. In your above comment you said to add code in ./ext/ai-admin-jqadm/admin/jqadm/src/ folder but in the link the writer asks to create class in this directory: ./<yourext>/lib/custom/src/MShop/Product/Item/Myproject.php
Afterwards, you can add your new field to the product basic panel. If you implemented toArray() and fromArray() of the item correctly, it will be saved by your extended saveItem() method of your manager.

Re: Aimeos Laravel Package - Add more fields in Product form

Posted: 02 Apr 2018, 05:38
by mohal_04
aimeos wrote:
mohal_04 wrote: What if I only want to add a new field in Product form in Admin Panel? I have followed all steps mentioned in following link: https://aimeos.org/docs/Developers/Libr ... gers_items
Yes, you have to follows the steps in that article and create an extended item and manager.
mohal_04 wrote: But new field value is not being saved. I am sure I am missing something. In your above comment you said to add code in ./ext/ai-admin-jqadm/admin/jqadm/src/ folder but in the link the writer asks to create class in this directory: ./<yourext>/lib/custom/src/MShop/Product/Item/Myproject.php
Afterwards, you can add your new field to the product basic panel. If you implemented toArray() and fromArray() of the item correctly, it will be saved by your extended saveItem() method of your manager.
Thank you so much for the help! I have nothing inside saveItem(). Can you guide me what to write in it? The input field name is "item[product.oldcode]"

Here is my code (copied as is)

Code: Select all

namespace Aimeos\MAdmin\Product\Manager;
 
class Myproject extends Standard
{
    private $searchConfig = array(
        'product.oldcode'=> array(
            'code'=>'product.oldcode',
            'internalcode'=>'mpro."oldcode"',
            'label'=>'Product oldcode',
            'type'=> 'string', // integer, float, etc.
            'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, // _INT, _FLOAT, etc.
        ),
    );
 
    public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
    {
        // a modified copy of the code from the parent class
        // extended by a bind() call and updated bind positions (first parameter)
    }
 
    public function getSearchAttributes( $withsub = true )
    {
        $list = parent::getSearchAttributes( $withsub );
        foreach( $this->searchConfig as $key => $fields ) {
            $list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard( $fields );
        }
        return $list;
    }
 
    protected function createItemBase( array $values = [] /* , ... */ )
    {
        return new \Aimeos\MShop\Product\Item\Myproject( $values /* , ... */ );
    }
}
Thanks!