You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When you copy a product, collection or other entity with associated assets to a new channel, the following error will be thrown:
TypeError: Cannot read properties of undefined (reading 'constructor')
at AssetService.createOrderableAssets (/Users/mschipperheyn/workspace/maos/node_modules/@vendure/core/src/service/services/asset.service.ts:615:6)
at AssetService.updateEntityAssets (/Users/mschipperheyn/workspace/maos/node_modules/@vendure/core/src/service/services/asset.service.ts:276:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async CollectionService.create (/Users/mschipperheyn/workspace/maos/node_modules/@vendure/core/src/service/services/collection.service.ts:465:9)
at async EntityDuplicator.duplicate [as duplicateFn] (/Users/mschipperheyn/workspace/maos/node_modules/@vendure/core/src/config/entity/entity-duplicators/collection-duplicator.ts:66:38)
at async /Users/mschipperheyn/workspace/maos/node_modules/@vendure/core/src/service/helpers/entity-duplicator/entity-duplicator.service.ts:76:35
The quickest workaround here is to not assume the existence of an asset in the array. However, the more correct solution would be to copy the asset as well.
The core problem, one that is hard to deal with, is that any referenced entity that is on the source channel does not get copied. This means that the copied entity will have references to entities in a different channel and any "findInChannel" style query that gets executed on that entity is a pre or post load / update will not find those associations. If you don't manually copy those associations, problems ensue.
We find ourselves also dealing with facet copy tasks. With post copy actions such as removing copy and (Copy) labels, which is a whole can of worms in itself since it triggers an indexing action that generates errors by itself.
To Reproduce
Steps to reproduce the behavior:
Copy a collection with an associated asset to a new channel
Expected behavior
Associated assets should also be copied to the new channel. At the very least, erors should be prevented.
In general, any copy action should offer the option to copy associations on a per association basis
Ideally, copy actions should offer some kind of post processing function that gives the source and the newly created copied entity. So that any non predictable post processing can be executed.
When you are copying to a new channel, it should be possible to disable the copy / (Copy) style label and slug changes through a setting.
Ideally would be nice to be able to disable the indexer for the purpose of these changes until after the whole operation is complete.
Environment (please complete the following information):
@vendure/core version: 2.2.2
Nodejs version 20
Database (mysql/postgres etc): postgres
**Additional context
We are creating a channel copy service that uses a template channel as an input in order to get a pre-configured channel ready for a new seller
The text was updated successfully, but these errors were encountered:
A workaround for the issue is to assign the to be copied entity to the target channel before copying (and removing after copying). That prevents the asset error occurring. But it doesn't resolve the other issues
A co-worker suggested that since the assets can't really be edited and can therefore just get a channel copy, and a delete on one channel would not impact another channel reference. Didn't check that yet
Describe the bug
When you copy a product, collection or other entity with associated assets to a new channel, the following error will be thrown:
The reason is this line
The quickest workaround here is to not assume the existence of an asset in the array. However, the more correct solution would be to copy the asset as well.
The core problem, one that is hard to deal with, is that any referenced entity that is on the source channel does not get copied. This means that the copied entity will have references to entities in a different channel and any "findInChannel" style query that gets executed on that entity is a pre or post load / update will not find those associations. If you don't manually copy those associations, problems ensue.
We find ourselves also dealing with facet copy tasks. With post copy actions such as removing copy and (Copy) labels, which is a whole can of worms in itself since it triggers an indexing action that generates errors by itself.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Associated assets should also be copied to the new channel. At the very least, erors should be prevented.
In general, any copy action should offer the option to copy associations on a per association basis
Ideally, copy actions should offer some kind of post processing function that gives the source and the newly created copied entity. So that any non predictable post processing can be executed.
When you are copying to a new channel, it should be possible to disable the
copy / (Copy)
style label and slug changes through a setting.Ideally would be nice to be able to disable the indexer for the purpose of these changes until after the whole operation is complete.
Environment (please complete the following information):
**Additional context
We are creating a channel copy service that uses a template channel as an input in order to get a pre-configured channel ready for a new seller
The text was updated successfully, but these errors were encountered: