BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Object queued for saving, but not saved #116

Closed ascheider closed 1 year ago

ascheider commented 1 year ago

I have currently problem with the import. The object variant is queued for saving, but never saved in full import context. If i import the object via preview it works fine. Data Director Version: 3.4.9 Full Log: full-log.txt Single log: single-log.txt Data Port Config: netherlands-import-european-variants.json.txt Search for the: SPMMA0120VVCL00 Saving #128226 is missing in full import

ascheider commented 1 year ago

@BlackbitDevs Do you have any idea, why it happens?

BlackbitDevs commented 1 year ago

What is the object ID / fullpath? /Product Catalogue/Sheet/PMMA/Röhm/PLEXIGLAS® GS/PLEXIGLAS® GS Acrylglas Platte/PLEXIGLAS® GS Acrylglas Platte 3050 x 2030 x 12 mm, Farblos? Hmm, actually it says object /Product Catalogue/Sheet/PMMA/Röhm/PLEXIGLAS® GS/PLEXIGLAS® GS Acrylglas Platte/PLEXIGLAS® GS Acrylglas Platte 3050 x 2030 x 12 mm, Farblos queued for saving. Think in 3.5 I have added a log entry when the object does not get saved. Do you have the chance to try of the problem still occurs in 3.5.x-dev? If it does not, I will try to spot the changes and backport them into 3.4.

ascheider commented 1 year ago

@BlackbitDevs Hi, yes the path is "/Product Catalogue/Sheet/PMMA/Röhm/PLEXIGLAS® GS/PLEXIGLAS® GS Acrylglas Platte/PLEXIGLAS® GS Acrylglas Platte 3050 x 2030 x 12 mm, Farblos" this is object variant. image Same result with 3.5 dev. Here the log: log_3.5-dev.txt Object id in pim is: 128226 There is no "Not saving object #128226" or "Successfully saved object #128226" in the log. Maybe something variant related here?

ascheider commented 1 year ago

@BlackbitDevs i debuged it further.

image image

log_with_debug.txt

The object is queued and and set in setCachedItem but not exists in getCachedItem

image

Also missing in saveItems item in cache: 128226

image

Could it be AbstractElement[]|SplObjectStorage issue? I'm pretty desparate on this point;)

ascheider commented 1 year ago

@BlackbitDevs Hi, it seems saveItems is not called for the elements: log_items.txt image If i change if($keyValueDatasetIndex > 0) to if($this->itemCache->count() > 0) i have somehow endless loop somewhere.

BlackbitDevs commented 1 year ago

@ascheider Can you try to enable "Compatibility mode" in dataport's advanced settings (on settings tab)? Does it work then?

sevarozh commented 1 year ago

The problem is with the nested iteration of $this->itemCache (lib/Pim/Item/Importer.php):

`foreach ($this->itemCache as $item) { ... $this->saveObject($item); ... }

private function saveObject(AbstractModel $item) { ... // HERE ITERATOR-KEY IS MOVED AT THE END foreach ($this->itemCache as $otherItem) { if ($item !== $otherItem && $item->getFullPath() === $otherItem->getFullPath() && !$this->isModified($item, $otherItem, null, false)) { $this->log($item, 'Latest draft version and latest published version of '.\Pimcore\Model\Element\Service::getElementType($item).' #'.$item->getId().' do not differ -> will not save new draft version', 'info'); $saveVersion = false; } } ... }`

Example in sandbox: https://onlinephp.io/c/5690e

Bildschirmfoto 2023-08-21 um 13 30 16

As a bug-fix you can use clone in the second loop:

Bildschirmfoto 2023-08-21 um 13 38 11
BlackbitDevs commented 1 year ago

Oh my goodness, @sevarozh thank you very much! I was not aware of this. Currently checking if there is a way without cloning... will fix this ASAP!

BlackbitDevs commented 1 year ago

@sevarozh, WDYT about https://onlinephp.io?s=jVNNb9swDD3XgP8DBwSIHSwI6tyWOdsOO_Q0YN2tKALFYWx1tmRIdLpg8H-f5M-68tAKOcTke498lPj5S5mVvrfZwHdBqOAqKwWJPCFkqPAjoHiS1w--t9AkFUsRYhD4DPdl_uP4hAndt-Eg3PmeQXHC4tZgAtlkw4clPy0h3sPt424UeWhxjwa4lAKXu44ZzTEjlxk1THqWA3M7x9y6zG3LzBQ2VX0vyZnW8BM1ErFjjndmCMwwgBdljgUK0tDHvqWpwpQR-t5f3wNzNqsVfL0wNUBgtWkzpeIXg4QFFwJVn25KTtKamKI7ccI_Q86Itn_AiJdMsWKUn8r1sL5mdcx5AudKJMSlgMMhkUKTqhIK_qMQtszOjj0Lyrhe7ycoMzPHxyv86MMBr_e_8do8EIuvhxG86jZF6hlB-Al-KXZBpe2dOD0qpEqJ2VbfqqLsTQfhS7WzVMiSLJh1zrQpU5QTgj38PIvvvEIcx-5kHJHRy26aqMfPejBU9xvW34ldRPflBv2LtxMfvPGXhuwmNM3cDPHofXo3jmDUKErKmiF0svVEer3vpm4FzM8szOFUFWXQNmKi9T8%2C&v=8.1.0

After looping the Iterator the reset() method sets the current key back to the initial value - without cloning / copying $this->itemCache.

BlackbitDevs commented 1 year ago

@ascheider Can you please try if the problem is solved in 3.4.x-dev? Alternatively you can also try 3.5.x-dev, the applied fix is the same.

sevarozh commented 1 year ago

@sevarozh, WDYT about https://onlinephp.io?s=jVNNb9swDD3XgP8DBwSIHSwI6tyWOdsOO_Q0YN2tKALFYWx1tmRIdLpg8H-f5M-68tAKOcTke498lPj5S5mVvrfZwHdBqOAqKwWJPCFkqPAjoHiS1w--t9AkFUsRYhD4DPdl_uP4hAndt-Eg3PmeQXHC4tZgAtlkw4clPy0h3sPt424UeWhxjwa4lAKXu44ZzTEjlxk1THqWA3M7x9y6zG3LzBQ2VX0vyZnW8BM1ErFjjndmCMwwgBdljgUK0tDHvqWpwpQR-t5f3wNzNqsVfL0wNUBgtWkzpeIXg4QFFwJVn25KTtKamKI7ccI_Q86Itn_AiJdMsWKUn8r1sL5mdcx5AudKJMSlgMMhkUKTqhIK_qMQtszOjj0Lyrhe7ycoMzPHxyv86MMBr_e_8do8EIuvhxG86jZF6hlB-Al-KXZBpe2dOD0qpEqJ2VbfqqLsTQfhS7WzVMiSLJh1zrQpU5QTgj38PIvvvEIcx-5kHJHRy26aqMfPejBU9xvW34ldRPflBv2LtxMfvPGXhuwmNM3cDPHofXo3jmDUKErKmiF0svVEer3vpm4FzM8szOFUFWXQNmKi9T8%2C&v=8.1.0

After looping the Iterator the reset() method sets the current key back to the initial value - without cloning / copying $this->itemCache.

Yes, it looks good!

ascheider commented 1 year ago

@BlackbitDevs i think we can close the issue. @sevarozh tested it already in the project. As i can see you already released the bugfix in 3.4.13. Thanks!

AndiKeiser commented 12 months ago

@BlackbitDevs Unfortunately the import still does not work for me. Single Log: single-log.txt Tried it with 3.4.14 and 3.5

BlackbitDevs commented 12 months ago

@AndiKeiser Can you try to enable "Compatibility mode" in dataport's advanced settings (on settings tab)? Does it work then?

AndiKeiser commented 11 months ago

@BlackbitDevs Sorry false alarm. It was Pimcore.