Batch updating products does not update the ElasticSearch index.
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!
Batch updating products does not update the ElasticSearch index.
Laravel framework version: 10.16.1
Aimeos Laravel version: 2023.04.*
PHP Version: 8.2.8
Environment: Linux
How to reproduce:
1) Have ai-elastic installed and working.
2) Go to product listing in the admin and make a batch change, for example increasing the product price with 10% by typing "10" in the field.
3) The product price is not updated in the frontend when the frontend is refreshed.
Are you able to reproduce this?
Aimeos Laravel version: 2023.04.*
PHP Version: 8.2.8
Environment: Linux
How to reproduce:
1) Have ai-elastic installed and working.
2) Go to product listing in the admin and make a batch change, for example increasing the product price with 10% by typing "10" in the field.
3) The product price is not updated in the frontend when the frontend is refreshed.
Are you able to reproduce this?
Re: Batch updating products does not update the ElasticSearch index.
We've updated the aimeos/ai-admin-jqadm:2023.07.x-dev package to use the index manager in the batch() method instead of the product manager. That should work for index-only setups too. Can you give it a try?
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: Batch updating products does not update the ElasticSearch index.
Due to breaking changes in the newer jqadm versions (more elements converted to use vue js), I have to stick to 2023.04.*.
Otherwise it breaks templates I've already changed in the backend.
How can I fix it without updating to 2023.07 ?
Otherwise it breaks templates I've already changed in the backend.
How can I fix it without updating to 2023.07 ?
Re: Batch updating products does not update the ElasticSearch index.
Temporarily, you can replace the batch() method with these lines:
https://github.com/aimeos/ai-admin-jqad ... p#L80-L106
Keep in mind that you have to update to 2023.10 LTS nevertheless because 2023.0x versions won't be supported any more if the LTS version is available.
https://github.com/aimeos/ai-admin-jqad ... p#L80-L106
Keep in mind that you have to update to 2023.10 LTS nevertheless because 2023.0x versions won't be supported any more if the LTS version is available.
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: Batch updating products does not update the ElasticSearch index.
It's working when I made the changes you suggested.
Can I make a pull request that adds this change to 2023.04.*?
Can I make a pull request that adds this change to 2023.04.*?
Re: Batch updating products does not update the ElasticSearch index.
Update: An error is showing
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '<ID>-product/property-default--1.' for key 'unq_msproli_pid_dm_ty_rid_sid': INSERT INTO "mshop_product_list" ( "parentid", "key", "type", "domain", "refid", "start", "end", "config", "pos", "status", "mtime", "editor", "siteid", "ctime" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ["139525","product\/property|default|","default","product\/property","",null,null,"[]",0,1,"2023-08-14 15:21:47","<EMAIL>","1.","2023-08-14 15:21:47"]
The error occurs in the newly added batch() method on this row:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '<ID>-product/property-default--1.' for key 'unq_msproli_pid_dm_ty_rid_sid': INSERT INTO "mshop_product_list" ( "parentid", "key", "type", "domain", "refid", "start", "end", "config", "pos", "status", "mtime", "editor", "siteid", "ctime" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ["139525","product\/property|default|","default","product\/property","",null,null,"[]",0,1,"2023-08-14 15:21:47","<EMAIL>","1.","2023-08-14 15:21:47"]
The error occurs in the newly added batch() method on this row:
Code: Select all
$manager->save( $items );
Re: Batch updating products does not update the ElasticSearch index.
Did you customize the batch section of the product list template?
Properties are not part of the batch update by default and in your setup, they are tried to be saved as list entries.
Properties are not part of the batch update by default and in your setup, they are tried to be saved as list entries.
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: Batch updating products does not update the ElasticSearch index.
I think that the only change to the batches I've done is here:
This changes it so that the percent discount is set based on the current price.
Code: Select all
Aimeos\Admin\JQAdm\Product\Price\Decorator
Code: Select all
/**
* Batch update of a resource
*
* @return string|null Output to display
*/
public function batch() : ?string
{
$view = $this->view();
$data = $view->param( 'price', [] );
foreach( $view->get( 'items', [] ) as $item )
{
foreach( $item->getRefItems( 'price' ) as $price )
{
$temp = $data;
$price->fromArray( $temp, true );
if( isset( $data['valuepercent'] ) ) {
$price->setValue( $price->getValue() + $price->getValue() * $data['valuepercent'] / 100 );
}
if( isset( $data['rebatepercent'] ) ) {
$current_price_value = (float) $price->getValue(); // Get the current price value
$original_price_value = (float) $current_price_value + $price->getRebate(); // Calculate the original price value
$rebatepercent = abs( (float) $data['rebatepercent'] ); // Get the new rebate percent
$new_rebate = $original_price_value * $rebatepercent / 100; // Calculate the new rebate value
$new_price = $original_price_value - $new_rebate; // Calculate the new price value
if( $new_price < 0 ) {
throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Price value "%s" with a discount of "%s" percent is invalid', $new_price, $rebatepercent ) );
}
$price->setValue( $new_price ); // Set the new price value
$price->setRebate( $new_rebate ); // Set the new rebate value
}
if( isset( $data['costspercent'] ) ) {
$price->setCosts( $price->getCosts() + $price->getCosts() * $data['costspercent'] / 100 );
}
}
}
return null;
}
Re: Batch updating products does not update the ElasticSearch index.
But we can't reproduce it in a test setup
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: Batch updating products does not update the ElasticSearch index.
I will keep investigating why it's happening, thank you