Unable to store new 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!
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Unable to store new product
Hello,
I'm trying to create a new product like this:
No error appear. But, it was not stored in the database.
this is the result
I'm trying to create a new product like this:
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'product' );
$item = $manager->create([
'product.code' => $code,
'product.type' => 'default',
'product.label' => $request->label,
'product.status' => 1,
'price' => [[
'price.label' => 'Demo: Article from 1',
'price.value' => $request->price,
'price.costs' => '0.00',
'price.rebate' => '0.00',
'price.taxrate' => $request->tax,
'price.quantity' => 1,
'price.type' => 'default',
'price.currencyid' => 'USD',
'price.status' => 1,
'product.lists.type' => 'default',
'product.lists.position' => 0
]],
]);
$item = $manager->save($item, true);
this is the result
Code: Select all
^ Aimeos\MShop\Product\Item\Standard {#339 ▼
-date: "2022-05-05 12:20:00"
-available: true
-modified: false
-prefix: "product."
#bdata: array:7 [▼
"product.code" => 476145
"product.type" => "default"
"product.label" => "Enim ea quos omnis i"
"product.status" => 1
"price" => array:1 [▶]
"product.siteid" => "1."
".date" => "2022-05-05 12:20:00"
]
-listItems: []
-listRefItems: []
-listRmItems: []
-listPrepared: true
-listRmMap: []
-listMap: []
-listMax: 0
-propItems: []
-propRmItems: []
-propMax: 0
}
Re: Unable to store new product
If you hand over the properties to create(), the item is not marked as modified and therefore not stored. Use fromArray() instead if you want to import/update products.
Adding prices that way doesn't work, you have to use addListItem() instead:
https://aimeos.org/docs/latest/models/m ... ated-items
Adding prices that way doesn't work, you have to use addListItem() instead:
https://aimeos.org/docs/latest/models/m ... 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