BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Error importing data to localized field in Field collection #141

Open Lars77 opened 9 months ago

Lars77 commented 9 months ago

I created a dataport for importing data from an Excel file. I want to Import the data to class ClassProduct. ClassProduct has a field called descriptionLong of type field collection. The allowed field collection is FiCoDescriptionLong.

Bildschirmfoto 2024-02-02 um 15 03 52

In the transformation settings of field descriptionLong I create an array as described in Pimcore-Data-Director-Manual page 16. For testing purpose I just return

return ['FiCoDescriptionLong' => [
    [
        'description#de_DE' => 'Beschreibung de_DE',
        'description#en' => 'Beschreibung EN',
        'description#de' => 'Beschreibung de',
        'pdmArticleId' => 4711,
        'targetGroup' => ['ClassCustomerSegment:key:O&P professionals']
    ],
    ]
];

If I run the import for 1 line I get the following output:

[INFO] Value for field descriptionLong: { "FiCoDescriptionLong": [ { "description#de_DE": "Beschreibung de_DE", "description#en": "Beschreibung EN", "description#de": "Beschreibung de", "pdmArticleId": 4711, "targetGroup": [ "ClassCustomerSegment:key:O&P professionals" ] } ] } -> [ [ { "FiCoDescriptionLong": [ { "description": "Beschreibung EN", "targetGroup": [ { "id": 18396, "className": "ClassCustomerSegment", "published": true, "key": "O&P professionals", "path": "/ClusterManagement/Target-Groups/B2B/", "query": "ClassCustomerSegment:path:\"/ClusterManagement/Target-Groups/B2B/O&P professionals\"", "tags": [], "properties": [], "comment": "In preview $params['currentObjectData'] supports max. nesting of 3 levels. If you need more, please use a virtual field with a data query selector." } ], "channel": [], "pdmArticleId": 4711 } ] } ] ] [INFO] Reason for saving: 1 [INFO] object /testprodukt queued for saving [ERROR] Object #18382 could not be saved. Reverted changes. Error: Error: Typed property Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData::$index must not be accessed before initialization in /var/www/html/vendor/pimcore/pimcore/models/DataObject/Fieldcollection/Data/AbstractData.php:46 Stack trace:

0 /var/www/html/vendor/pimcore/pimcore/models/DataObject/ClassDefinition/Data/Relations/AbstractRelations.php(388): Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData->getIndex()

1 /var/www/html/vendor/pimcore/pimcore/models/DataObject/ClassDefinition/Data/ManyToManyObjectRelation.php(375): Pimcore\Model\DataObject\ClassDefinition\Data\Relations\AbstractRelations->loadLazyFieldcollectionField(Object(Pimcore\Model\DataObject\Fieldcollection\Data\FiCoDescriptionLong))

2 /var/www/html/var/classes/DataObject/Fieldcollection/Data/FiCoDescriptionLong.php(101): Pimcore\Model\DataObject\ClassDefinition\Data\ManyToManyObjectRelation->preGetData(Object(Pimcore\Model\DataObject\Fieldcollection\Data\FiCoDescriptionLong))

3 /var/www/html/vendor/pimcore/pimcore/models/DataObject/ClassDefinition/Data/Fieldcollections.php(347): Pimcore\Model\DataObject\Fieldcollection\Data\FiCoDescriptionLong->getTargetGroup()

4 /var/www/html/vendor/pimcore/pimcore/models/DataObject/Concrete.php(386): Pimcore\Model\DataObject\ClassDefinition\Data\Fieldcollections->resolveDependencies(Object(Pimcore\Model\DataObject\Fieldcollection))

5 /var/www/html/vendor/pimcore/pimcore/models/DataObject/AbstractObject.php(745): Pimcore\Model\DataObject\Concrete->resolveDependencies()

6 /var/www/html/vendor/pimcore/pimcore/models/DataObject/Concrete.php(214): Pimcore\Model\DataObject\AbstractObject->update(true, Array)

7 /var/www/html/vendor/pimcore/pimcore/models/DataObject/AbstractObject.php(578): Pimcore\Model\DataObject\Concrete->update(true, Array)

8 /var/www/html/vendor/pimcore/pimcore/models/DataObject/Concrete.php(697): Pimcore\Model\DataObject\AbstractObject->save(Array)

9 /var/www/html/vendor/blackbit/data-director/lib/Pim/Item/Importer.php(6097): Pimcore\Model\DataObject\Concrete->save(Array)

10 /var/www/html/vendor/blackbit/data-director/lib/Pim/Item/Importer.php(9513): Blackbit\DataDirectorBundle\lib\Pim\Item\Importer->saveObject(Object(Pimcore\Model\DataObject\ClassProduct))

11 /var/www/html/vendor/blackbit/data-director/lib/Pim/Item/Importer.php(978): Blackbit\DataDirectorBundle\lib\Pim\Item\Importer->saveItems(Array)

12 /var/www/html/vendor/blackbit/data-director/lib/Pim/Item/Importmanager.php(932): Blackbit\DataDirectorBundle\lib\Pim\Item\Importer->import(Array, Array, Object(stdClass))

13 /var/www/html/vendor/blackbit/data-director/lib/Pim/Item/Importmanager.php(640): Blackbit\DataDirectorBundle\lib\Pim\Item\Importmanager->processChunk(Array, INF, 0, 100, 0, Array, Object(stdClass), '65bcf3d2d88520....', Array, Array, Array, Object(Blackbit\DataDirectorBundle\lib\Pim\Logger\FileObject), Array, Array, 0, 1, 0, Object(Blackbit\DataDirectorBundle\lib\Pim\BackingUpResponse), NULL)

14 /var/www/html/vendor/blackbit/data-director/Command/ImportPimCommand.php(309): Blackbit\DataDirectorBundle\lib\Pim\Item\Importmanager->importDataport(Array, 1, Array, '65bcf3d2d88520....', NULL)

15 /var/www/html/vendor/blackbit/data-director/Command/ImportPimCommand.php(202): Blackbit\DataDirectorBundle\Command\ImportPimCommand::import(1, Array, Array, true, NULL, NULL, '65bcf3d2d88520....', Object(Symfony\Component\Console\Output\ConsoleOutput))

16 /var/www/html/vendor/symfony/console/Command/Command.php(326): Blackbit\DataDirectorBundle\Command\ImportPimCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

17 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

18 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(91): Symfony\Component\Console\Application->doRunCommand(Object(Blackbit\DataDirectorBundle\Command\ImportPimCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

19 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Blackbit\DataDirectorBundle\Command\ImportPimCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

20 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

21 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

22 /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php(54): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

23 /var/www/html/vendor/autoload_runtime.php(29): Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run()

24 /var/www/html/bin/console(20): require_once('/var/www/html/v...')

25 {main}

It seems that only the current locale is used for importing data, because only the value for en is imported, regardless of the order in the array.

BlackbitDevs commented 3 months ago

Sorry for late response. Does this problem still exist with latest 3.6?