Extend Product/Text

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!
heural
Posts: 58
Joined: 09 Jun 2022, 07:55

Extend Product/Text

Post by heural » 24 Feb 2023, 07:49

Hi Aimeos Team,

I tried to extend Product/Text, as shown in the attachment. Extending the template was´nt the problem but now, I struggled with save and retrieve the data.
I´ve looked into https://aimeos.org/docs/2021.x/models/e ... custom-way but I dont know the "connection" beetween my own Text/Lists/Manager to include the "contentimage" and extend the product.lists-table

With extending config/mshop/product.php, the product-tab shows a SQL-Syntax-Error:

Code: Select all

return array(
    'manager' => array(
        'lists' => array(
        'insert' => array(
                'ansi' => '
                    INSERT INTO "mshop_product_list" ( :names
                        "parentid", "key", "type", "domain", "refid", "start", "end",
                        "config", "pos", "status", "mtime", "editor", "siteid", "ctime", "contentimage"
                    ) VALUES ( :values
                        ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
                    )
                '
                ),
                'update' => array(
                    'ansi' => '
                        UPDATE "mshop_product_list"
                        SET :names
                            "parentid" = ?, "key" = ?, "type" = ?, "domain" = ?, "refid" = ?, "start" = ?,
                            "end" = ?, "config" = ?, "pos" = ?, "status" = ?, "mtime" = ?, "editor" = ?, "contentimage" = ?
                        WHERE "siteid" LIKE ? AND "id" = ?
                    '
                ),
                'search' => array(
                    'ansi' => '
                        SELECT :columns
                            mproli."id" AS "product.lists.id", mproli."parentid" AS "product.lists.parentid",
                            mproli."siteid" AS "product.lists.siteid", mproli."type" AS "product.lists.type",
                            mproli."domain" AS "product.lists.domain", mproli."refid" AS "product.lists.refid",
                            mproli."start" AS "product.lists.datestart", mproli."end" AS "product.lists.dateend",
                            mproli."config" AS "product.lists.config", mproli."pos" AS "product.lists.position",
                            mproli."status" AS "product.lists.status", mproli."mtime" AS "product.lists.mtime",
                            mproli."editor" AS "product.lists.editor", mproli."ctime" AS "product.lists.ctime",
                            mproli."contentimage" AS "product.lists.contentimage"
                        FROM "mshop_product_list" mproli
                        :joins
                        WHERE :cond
                        ORDER BY :order
                        OFFSET :start ROWS FETCH NEXT :size ROWS ONLY
                    ',
                    'mysql' => '
                        SELECT :columns
                            mproli."id" AS "product.lists.id", mproli."parentid" AS "product.lists.parentid",
                            mproli."siteid" AS "product.lists.siteid", mproli."type" AS "product.lists.type",
                            mproli."domain" AS "product.lists.domain", mproli."refid" AS "product.lists.refid",
                            mproli."start" AS "product.lists.datestart", mproli."end" AS "product.lists.dateend",
                            mproli."config" AS "product.lists.config", mproli."pos" AS "product.lists.position",
                            mproli."status" AS "product.lists.status", mproli."mtime" AS "product.lists.mtime",
                            mproli."editor" AS "product.lists.editor", mproli."ctime" AS "product.lists.ctime",
                            mproli."contentimage" AS "product.lists.contentimage"
                        FROM "mshop_product_list" mproli
                        :joins
                        WHERE :cond
                        ORDER BY :order
                        LIMIT :size OFFSET :start
                    '
                ),
            ),
        ),
);

Thank you!
Attachments
screenshot-aimeos.local-2023.02.23-15_37_59.png
screenshot-aimeos.local-2023.02.23-15_37_59.png (70.37 KiB) Viewed 1349 times

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

Re: Extend Product/Text

Post by aimeos » 27 Feb 2023, 09:15

Well, there's none for good reasons! Usually, you want to keep things separate and upload an image with a new type instead in the media panel to be able to enforce the layout in the frontend.

If you really want to directly connect texts and images and let the editor influence the layout (which then may look broken), you can store the uploaded file by the media manager and add an hint to the ID of the media item in the "config" field of the list item. In the frontend, you have to bring that together based on the "config" value.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply