woocommerce migration not working for nested categories
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
woocommerce migration not working for nested categories
I'm using aimeos-laravel 2024.10.3 with ai-woocommerce 2024.10.1
Running the WC migration I'm getting a Aimeos\MW\Tree\Exception
No node with ID "571" found.
It's being triggered by WooMigrateCategories, line 60.
I see that what's happening is when it inserts the categories it pulled from WC it's not keeping the existing IDs (term_id in the WP query) instead it's assigning new auto-incremented IDs. So when it hits a record with an existing parent_id (in my case 571) it's erroring out because the parent was assigned a new id, 571 doesn't exist. -and if it did exist it would most likely be the wrong record.
Running the WC migration I'm getting a Aimeos\MW\Tree\Exception
No node with ID "571" found.
It's being triggered by WooMigrateCategories, line 60.
I see that what's happening is when it inserts the categories it pulled from WC it's not keeping the existing IDs (term_id in the WP query) instead it's assigning new auto-incremented IDs. So when it hits a record with an existing parent_id (in my case 571) it's erroring out because the parent was assigned a new id, 571 doesn't exist. -and if it did exist it would most likely be the wrong record.
Re: woocommerce migration not working for nested categories
So it's already a problem in your Woocommerce data? If yes, fix the data in Woocommerce first and then try the migration again.
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: woocommerce migration not working for nested categories
I'm not sure what you mean by a "problem" in my WooCommerce data? Is this not how WooCommerce is supposed to work?
It seems to me that we should be keeping the existing WooCommerce IDs anyways, not assigning new ones. Presumably anyone migrating from WC has an existing store and will likely have all kinds of compatibility problems if the WC IDs aren't kept.
It seems to me that we should be keeping the existing WooCommerce IDs anyways, not assigning new ones. Presumably anyone migrating from WC has an existing store and will likely have all kinds of compatibility problems if the WC IDs aren't kept.
Re: woocommerce migration not working for nested categories
The ID of the category is set to the original Woocommerce ID immediately in the next line with the update() statement as it's not possible in Aimeos to create a category item with an assigned ID in the database:
Can you post the full stack trace of the exception you are encountering?
Code: Select all
$item = $manager->insert( $item, $parent?->getId() );
$db2->update( 'mshop_catalog', ['id' => $row['term_id']], ['id' => $item->getId()] );
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: woocommerce migration not working for nested categories
Code: Select all
Aimeos\MW\Tree\Exception
No node with ID "571" found
at vendor/aimeos/aimeos-core/src/MW/Tree/Manager/DBNestedSet.php:702
698▕ $stmt->bind( 2, 0, \Aimeos\Base\DB\Statement\Base::PARAM_INT );
699▕ $result = $stmt->execute();
700▕
701▕ if( ( $row = $result->fetch() ) === null ) {
➜ 702▕ throw new \Aimeos\MW\Tree\Exception( sprintf( 'No node with ID "%1$d" found', $id ) );
703▕ }
704▕
705▕ return $this->createNodeBase( $row );
706▕ }
1 vendor/aimeos/aimeos-core/src/MW/Tree/Manager/DBNestedSet.php:187
Aimeos\MW\Tree\Manager\DBNestedSet::getNodeById()
2 vendor/aimeos/aimeos-core/src/MW/Tree/Manager/DBNestedSet.php:243
Aimeos\MW\Tree\Manager\DBNestedSet::getNode()
3 vendor/aimeos/aimeos-core/src/MShop/Catalog/Manager/Standard.php:537
Aimeos\MW\Tree\Manager\DBNestedSet::insertNode()
4 vendor/aimeos/aimeos-core/src/MShop/Common/Manager/Decorator/Base.php:50
Aimeos\MShop\Catalog\Manager\Standard::insert()
5 vendor/aimeos/aimeos-core/src/MShop/Common/Manager/Decorator/Base.php:50
6 vendor/aimeos/aimeos-core/src/MShop/Common/Manager/Decorator/Base.php:50
Aimeos\MShop\Common\Manager\Decorator\Base::__call()
7 vendor/aimeos/aimeos-core/src/MShop/Common/Manager/Decorator/Base.php:50
8 vendor/aimeos/ai-woocommerce/setup/WooMigrateCategories.php:60
Aimeos\MShop\Common\Manager\Decorator\Base::__call()
9 vendor/aimeos/upscheme/src/Up.php:364
Aimeos\Upscheme\Task\WooMigrateCategories::up()
10 vendor/aimeos/upscheme/src/Up.php:191
Aimeos\Upscheme\Up::runTasks()
11 vendor/aimeos/aimeos-core/Setup.php:84
Aimeos\Upscheme\Up::up()
12 vendor/aimeos/aimeos-laravel/src/Command/SetupCommand.php:65
Aimeos\Setup::up()
13 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
Aimeos\Shop\Command\SetupCommand::handle()
14 vendor/laravel/framework/src/Illuminate/Container/Util.php:43
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
15 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95
Illuminate\Container\Util::unwrapIfClosure()
16 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
Illuminate\Container\BoundMethod::callBoundMethod()
17 vendor/laravel/framework/src/Illuminate/Container/Container.php:694
Illuminate\Container\BoundMethod::call()
18 vendor/laravel/framework/src/Illuminate/Console/Command.php:213
Illuminate\Container\Container::call()
19 vendor/symfony/console/Command/Command.php:279
Illuminate\Console\Command::execute()
20 vendor/laravel/framework/src/Illuminate/Console/Command.php:182
Symfony\Component\Console\Command\Command::run()
21 vendor/symfony/console/Application.php:1094
Illuminate\Console\Command::run()
22 vendor/symfony/console/Application.php:342
Symfony\Component\Console\Application::doRunCommand()
23 vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application::doRun()
24 vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:197
Symfony\Component\Console\Application::run()
25 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
Re: woocommerce migration not working for nested categories
Strange. Can you please check why the $db2->update() statement doesn't set the mshop_catalog.id values after insertion to the original Woocommerce IDs?
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: woocommerce migration not working for nested categories
So I'm not sure I understand 100% what's going on, but I was able to get it to work by changing line 37 of WooMigrateCatagories.php from to
Code: Select all
$db2 = $this->db( 'db-catalog' );
Code: Select all
$db2 = $this->db( 'db' );
Re: woocommerce migration not working for nested categories
How does your "resource" section in your ./config/shop.php looks like?
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: woocommerce migration not working for nested categories
The only db things it has is the "main"
and the "db-woocommerce" one I added for the migration.
What I was unsure about is what $this->db( 'db-catalog' ) is supposed to be connecting to. If it's a non-existent db connection shouldn't that throw an error? and if it's the wrong db shouldn't the $db2->update() throw an error for table not found?
Code: Select all
'db' => [
'adapter' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.driver', 'mysql' ),
'host' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.host', '127.0.0.1' ),
'port' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.port', '3306' ),
'socket' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.unix_socket', '' ),
'database' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.database', 'forge' ),
'username' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.username', 'forge' ),
'password' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.password', '' ),
'stmt' => config( 'database.default', 'mysql' ) === 'mysql' ? ["SET SESSION sort_buffer_size=2097144; SET NAMES 'utf8mb4'; SET SESSION sql_mode='ANSI'"] : [],
'limit' => 3, // maximum number of concurrent database connections
'defaultTableOptions' => [
'charset' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.charset' ),
'collate' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.collation' ),
],
'driverOptions' => config( 'database.connections.' . config( 'database.default', 'mysql' ) . '.options' ),
],
What I was unsure about is what $this->db( 'db-catalog' ) is supposed to be connecting to. If it's a non-existent db connection shouldn't that throw an error? and if it's the wrong db shouldn't the $db2->update() throw an error for table not found?
Re: woocommerce migration not working for nested categories
If "db-catalog" doesn't exist, it falls back to the first database connection. Therefore, your "db" configuration must be always first:
Code: Select all
'resource' => [
'db' => [
// ...
],
'db-woocommerce' => [
// ...
]
],
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