Associate existed attributes with created product

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!
User avatar
AndreyFedotov
Posts: 3
Joined: 01 Mar 2021, 10:52

Associate existed attributes with created product

Post by AndreyFedotov » 09 Mar 2021, 05:02

Hi every one. I have task to create artisan command to create products and populate database with entries from external resource.
I've managed to create product using Aimeos Manager like this:

Code: Select all

        $productsManager = MShop::create($this->context, 'product');
        $item = $productsManager->create();
        $itemArray = [
            'product.code'   => 'test',
            'product.label'  => 'Test',
            'product.status' => 1,
            'product.type'   => 'default',
        ];
        $item->fromArray($itemArray, true);
        $createdProduct = $productsManager->save($item);
The question is how can I associate attributes with created product entry?
P.S. I already have attributes created in database and their ids.

Laravel 8, aimeos-laravel ~2020.10, php 8.0, Win 10 x64

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

Re: Associate existed attributes with created product

Post by aimeos » 09 Mar 2021, 18:11

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

sirick
Posts: 3
Joined: 23 Feb 2024, 21:11

Re: Associate existed attributes with created product

Post by sirick » 28 Feb 2024, 00:39

I have the exact same question but I couldn't find a solution in the Docs. From what I understand, we must create a manager for each database table (domain) and poppulate it ourselves? Isn't there a mechanism to associate attributes with products or category with products etc?

Code: Select all

$manager = \Aimeos\MShop::create( $this->context(), 'product' );
        $attributeManager = \Aimeos\MShop::create( $this->context(), 'attribute' );
        $listmanager = $manager->getSubManager('lists');
...
poppulate with attributes
...
$manager->save($item);

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

Re: Associate existed attributes with created product

Post by aimeos » 01 Mar 2024, 13:18

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

Post Reply