Product list item is not saving nor deleting
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!
Product list item is not saving nor deleting
Laravel framework version: 10.16.1
Aimeos Laravel version: 2023.04.*
PHP Version: 8.2.8
Environment: Linux
I can't seem to get this working, is it because of the custom list type?
I added a new Aimeos\Admin\JQAdm\Product\Related\Custom.
Also added a new template, which adds a third box in the "related products" section in the admin product page.
The saving works for the related product tabs in the admin, but saving programmatically seems to fail.
Am I doing something wrong?
Save:
Delete:
Aimeos Laravel version: 2023.04.*
PHP Version: 8.2.8
Environment: Linux
I can't seem to get this working, is it because of the custom list type?
I added a new Aimeos\Admin\JQAdm\Product\Related\Custom.
Also added a new template, which adds a third box in the "related products" section in the admin product page.
The saving works for the related product tabs in the admin, but saving programmatically seems to fail.
Am I doing something wrong?
Save:
Code: Select all
$product_manager = \Aimeos\MShop::create( $this->context, 'product' );
$index_manager = \Aimeos\MShop::create( $this->context, 'index' );
$product_manager->begin();
$product_item = $product_manager->get( <ID> );
$product_ref_item = $product_manager->get( <REF ID> );
$product_list_item = $product_manager->createListItem()->setType('custom-type');
$product_item->addListItem( 'product', $product_list_item, $product_ref_item );
$product_manager->save( $product_item );
$product_manager->commit();
$index_manager->rebuild( [ $product_item ] );
Code: Select all
$product_manager = \Aimeos\MShop::create( $this->context, 'product' );
$product_manager->begin();
$product_item = $product_manager->get( <ID> );
$list_items = $product_item->getListItems( 'product', 'custom-type', null, false );
$product_item->deleteListItems( $list_items );
$product_manager->save( $product_item );
$product_manager->commit();
$index_manager->rebuild( [ $product_item ] )
Re: Product list item is not saving nor deleting
I did some digging and I found the following.
Apart from the $product_manager transaction, I also begin a $stock_manager transaction:
$stock_manager->begin();
It seems like both transactions need to be finished for the product to be saved.
Is this behavior intended?
Apart from the $product_manager transaction, I also begin a $stock_manager transaction:
$stock_manager->begin();
It seems like both transactions need to be finished for the product to be saved.
Is this behavior intended?
Re: Product list item is not saving nor deleting
This is a side effect of the shared database connections. Each data domain (product, stock. etc.) uses the same database connection if not told otherwise.
If you open two transactions, one in the product manager and one in the stock manager, the transaction requests are stacked and you need to call two times commit() to actually commit the transactions.
If you open two transactions, one in the product manager and one in the stock manager, the transaction requests are stacked and you need to call two times commit() to actually commit the transactions.
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