Associate existed attributes with created product
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- AndreyFedotov
- Posts: 3
- Joined: 01 Mar 2021, 10:52
Associate existed attributes with created product
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:
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
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);
P.S. I already have attributes created in database and their ids.
Laravel 8, aimeos-laravel ~2020.10, php 8.0, Win 10 x64
Re: Associate existed attributes with created product
Please have a look here:
https://aimeos.org/docs/latest/infrastr ... ated-items
https://aimeos.org/docs/latest/infrastr ... ated-items
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Associate existed attributes with created product
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?
...
poppulate with attributes
...
$manager->save($item);
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);
Re: Associate existed attributes with created product
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star