Aimeos Laravel Package - Add more fields in Product form

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

Aimeos Laravel Package - Add more fields in Product form

Post by mohal_04 » 27 Mar 2018, 06:03

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!

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

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

Post by aimeos » 27 Mar 2018, 07:30

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?
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: Aimeos Laravel Package - Add more fields in Product form

Post by mohal_04 » 27 Mar 2018, 08:01

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!!!

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

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

Post by aimeos » 27 Mar 2018, 08:21

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
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: Aimeos Laravel Package - Add more fields in Product form

Post by mohal_04 » 27 Mar 2018, 10: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!

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

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

Post by mohal_04 » 27 Mar 2018, 10:19

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!

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

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

Post by aimeos » 28 Mar 2018, 08:02

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.
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: Aimeos Laravel Package - Add more fields in Product form

Post by mohal_04 » 30 Mar 2018, 11:56

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!

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

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

Post by aimeos » 31 Mar 2018, 17:18

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.
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: Aimeos Laravel Package - Add more fields in Product form

Post by mohal_04 » 02 Apr 2018, 05:38

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!

Post Reply