How can I create a new field in the "BASIC" section of the product card?

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!
santfather
Posts: 27
Joined: 02 Feb 2022, 10:43

How can I create a new field in the "BASIC" section of the product card?

Post by santfather » 02 Feb 2022, 11:03

Laravel version: 8.80
Aimeos version: 2021.10
PHP version: 8.0.8
WIN user

How can I create a new field in the "BASIC" section of the product card (in the admin panel), so that I can then filter products by this field?
Screenshot_9.png
Screenshot_9.png (110.21 KiB) Viewed 2075 times
I duplicated the code of one component. based on it, I want to make my own field by which I can filter products. Where and in what area do you need to make changes?

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

Re: How can I create a new field in the "BASIC" section of the product card?

Post by aimeos » 02 Feb 2022, 17:08

First, you need to add a new column to the mshop_product table and create a decorator for the product manager so it will know how to save and search your new property:
https://aimeos.org/docs/latest/models/extend-managers/

Then, you can use that property in the list template:
- https://github.com/aimeos/ai-admin-jqad ... #L530-L548
- https://github.com/aimeos/ai-admin-jqad ... #L644-L668
- https://github.com/aimeos/ai-admin-jqad ... d.php#L512

Add the property in the item template too so editors can change it:
https://github.com/aimeos/ai-admin-jqad ... #L343-L357

That's all.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

santfather
Posts: 27
Joined: 02 Feb 2022, 10:43

Re: How can I create a new field in the "BASIC" section of the product card?

Post by santfather » 10 Feb 2022, 13:28

I took "product.code" as a basis
and added my "product.modelfamily" field to the files:
1. aimeos\vendor\aimeos\ai-admin-jqadm\admin\jqadm\templates\product\list-standard.php
2. aimeos\vendor\aimeos\ai-admin-jqadm\admin\jqadm\templates\product\item-standard.php
3. aimeos\vendor\aimeos\ai-admin-jqadm\admin\jqadm\templates\product\item-selection-standard.php
4. aimeos\vendor\aimeos\aimeos-core\lib\mshoplib\config\mshop\product.php
5. aimeos\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Product\Item\Iface.php
6. aimeos\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Product\Item\Standard.php
7. aimeos\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Product\Manager\Standard.php
after all the manipulations, I see a new column and the values in it.
Screenshot_17.png
Screenshot_17.png (123.16 KiB) Viewed 2021 times
moreover, sorting in descending and ascending order works, as well as searching by ID
BUT, I can't enter data (correct, add or delete) in the product.modelfamily field from the admin panel. Only through the database. although a message about a successful operation appears
Screenshot_18.png
Screenshot_18.png (92.65 KiB) Viewed 2021 times

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

Re: How can I create a new field in the "BASIC" section of the product card?

Post by aimeos » 11 Feb 2022, 14:27

Don't change the files in the Aimeos core or the Aimeos extensions!
You will loose all your changes when running "composer update"!

Instead, create your own extension:
https://aimeos.org/docs/latest/developer/extensions/

Implement a decorator to extend the product manager:
https://aimeos.org/docs/latest/models/extend-managers/

Copy and adapt the product/item-standard.php template in your own extension:
https://aimeos.org/docs/latest/admin/jq ... templates/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply