Unable to retrieve custom fields from products table

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!
milos_shomsy
Posts: 7
Joined: 03 Aug 2020, 13:30

Unable to retrieve custom fields from products table

Post by milos_shomsy » 10 Aug 2020, 08:23

Hello,

I want to customise (simplify) product view and product table but still use amazing Managers.

I made custom decorator in my extension called "material-theme", and I would like to retreive these fields using product manager.

Extension looks like this:
https://paste.pics/f61ee711b38e0fe33bbfe1ade0f228a8

Decorator file looks like this:

Code: Select all

<?php

use Aimeos\MW\Criteria\Attribute\Iface;
use Aimeos\MW\Criteria\Attribute\Standard;

class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
    private $attr = [
        'mshop_product.showOnPage' => [
            'code' => 'mshop_product.showOnPage',
            'internalcode' => 'mpro."showOnPage"',
            'label' => 'Show on Page',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
        'mshop_product.name' => [
            'code' => 'mshop_product.name',
            'internalcode' => 'mpro."name"',
            'label' => 'Product Name',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
        'mshop_product.barcode' => [
            'code' => 'mshop_product.barcode',
            'internalcode' => 'mpro."barcode"',
            'label' => 'Barcode',
            'type' => 'integer',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
        ],
        'mshop_product.tag' => [
            'code' => 'mshop_product.tag',
            'internalcode' => 'mpro."tag"',
            'label' => 'Tag',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
        'mshop_product.price' => [
            'code' => 'mshop_product.price',
            'internalcode' => 'mpro."price"',
            'label' => 'Price',
            'type' => 'integer',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT,
        ],
        'mshop_product.currency' => [
            'code' => 'mshop_product.currency',
            'internalcode' => 'mpro."currency"',
            'label' => 'Currency',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
        'mshop_product.stock' => [
            'code' => 'mshop_product.stock',
            'internalcode' => 'mpro."stock"',
            'label' => 'Stock',
            'type' => 'integer',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
        ],
    ];

    /**
     * @return Standard[]|array
     */
    public function getSaveAttributes(): array
    {
        return parent::getSaveAttributes() + $this->createAttributes($this->attr);
    }

    /**
     * @param bool $sub
     * @return Iface[]|Standard[]
     */
    public function getSearchAttributes($sub = true): array
    {
        return parent::getSearchAttributes($sub) + $this->createAttributes($this->attr);
    }
}

I have configuration in folder like documentation says:
https://paste.pics/5525ae7e69edec215f31b271d3062cd0

And it's:

Code: Select all

<?php

return [
    'product' => [
        'manager' => [
            'decorators' => [
                'local' => ['Myproject']
            ]
        ]
    ]
];
But when I try to fetch, I have error:

Class "\Aimeos\MShop\Product\Manager\Decorator\Myproject" not available in file /var/www/html/app/Services/Shop/ProductsService.php on line 33

Do I miss something, please?

Thanks in advance,
Milos

milos_shomsy
Posts: 7
Joined: 03 Aug 2020, 13:30

Re: Unable to retrieve custom fields from products table

Post by milos_shomsy » 10 Aug 2020, 10:33

OK, it was the wrong namespace problem.

Now I have next challenge:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mshop_product.show_on_page' in 'field list': INSERT INTO "mshop_product" ( "mshop_product.show_on_page", "mshop_product.name", "mshop_product.barcode", "mshop_product.tag", "mshop_product.price", "mshop_product.currency", "mshop_product.stock", "type", "code", "dataset", "label", "url", "status", "scale", "start", "end", "config", "target", "editor", "mtime", "ctime", "siteid" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
I have custom action and controller where I want to save this data, but nothing special about that.
Is anything else I need to configure insertations?

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

Re: Unable to retrieve custom fields from products table

Post by aimeos » 11 Aug 2020, 06:34

Seems you haven't extended the schema yet:
https://aimeos.org/docs/Developers/Libr ... s#Easy_way
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply