Closed adhocore closed 4 years ago
@adhocore Content staging is not supported, but for sure it should not fail if row_id
and entity_id
will not be same. We've many examples here where they are different, it would be very helpful, if you can add a stacktrace here, so we can try to reproduce the issue :-)
thanks for response.
in some cases if row_id and entity_id are different (more precisely when entity_id > row_id) it seems to insert/update product attribute values for wrong sku (i.e. wrt entity_id and not row_id). - illustration in below thread
the integrity constraint violation occurs on updating an sku with row_id and entity_id different (adding seems to be working).
will update more with examples ...
sample csv:
sku,product_type,attribute_set_code,store_view_code,name,description,short_description,visibility,tax_class_id
"test_1",simple,Default,eng_view,"test_1 LIjh jIJb ALJ A DJhDDL","test_1 JeAB ihDk DJe D BjJkCECfBCG ag k IGaC cCLcIikcA IJIKBD CDhKkfe BBkbGkfah Eg G EiLDcB aiCidjcKkJBEdjEkIccbK L c D IHjbki kgdHka E jCDhaI d kg kA LiCeDed kdJJCDdCgacchgKJ bEIbf HFf LJ GDH F geiGgg CfiEI faLf ej E H eIfAbHGaL HLbckL","test_1 AchkjI k acCg A Lbb BcedKC LGE b J IiAAcjHfCCeLF BkhJe jE AfbgAELaGIi a bIDjHjefg DFfH fhbA","Catalog, Search","Taxable Goods"
stack trace:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento2`.`catalog_product_entity_varchar`, CONSTRAINT `CAT_PRD_ENTT_VCHR_ROW_ID_CAT_PRD_ENTT_ROW_ID` FOREIGN KEY (`row_id`) REFERENCES `catalog_product_entity` (`row_id`) ON DELETE CASCADE) in ./vendor/techdivision/import/src/Actions/Processors/AbstractBaseProcessor.php:166
Stack trace:
#0 ./vendor/techdivision/import/src/Actions/Processors/AbstractBaseProcessor.php(166): PDOStatement->execute(Array)
#1 ./vendor/techdivision/import-product/src/Actions/Processors/ProductVarcharCreateProcessor.php(64): TechDivision\Import\Actions\Processors\AbstractBaseProcessor->execute(Array, NULL)
#2 ./vendor/techdivision/import/src/Actions/GenericIdentifierAction.php(67): TechDivision\Import\Product\Actions\Processors\ProductVarcharCreateProcessor->execute(Array, NULL, 'value_id')
#3 ./vendor/techdivision/import/src/Actions/GenericIdentifierAction.php(54): TechDivision\Import\Actions\GenericIdentifierAction->create(Array, NULL)
#4 ./vendor/techdivision/import-product/src/Services/ProductBunchProcessor.php(1055): TechDivision\Import\Actions\GenericIdentifierAction->persist(Array, NULL)
#5 ./vendor/techdivision/import-product/src/Observers/ProductAttributeObserver.php(199): TechDivision\Import\Product\Services\ProductBunchProcessor->persistProductVarcharAttribute(Array)
#6 ./vendor/techdivision/import/src/Observers/AttributeObserverTrait.php(282): TechDivision\Import\Product\Observers\ProductAttributeObserver->persistVarcharAttribute(Array)
#7 ./vendor/techdivision/import/src/Observers/AbstractAttributeObserver.php(60): TechDivision\Import\Product\Ee\Observers\EeProductAttributeUpdateObserver->process()
#8 ./vendor/techdivision/import/src/Observers/GenericCompositeObserver.php(117): TechDivision\Import\Observers\AbstractAttributeObserver->handle(Object(TechDivision\Import\Product\Ee\Subjects\EeBunchSubject))
#9 ./vendor/techdivision/import/src/Subjects/AbstractSubject.php(986): TechDivision\Import\Observers\GenericCompositeObserver->handle(Object(TechDivision\Import\Product\Ee\Subjects\EeBunchSubject))
#10 ./src/Import/Adapter/Json.php(120): TechDivision\Import\Subjects\AbstractSubject->importRow(Array)
#11 [internal function]: Central\Leia\Import\Adapter\Json->Central\Leia\Import\Adapter\{closure}(Array)
#12 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(149): call_user_func(Object(Closure), Array)
#13 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(135): TechDivision\Import\Adapter\Goodby\Interpreter->delegate(Object(Closure), Array)
#14 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(74): TechDivision\Import\Adapter\Goodby\Interpreter->notify(Array)
#15 ./vendor/techdivision/import/src/Adapter/Goodby/Lexer.php(120): TechDivision\Import\Adapter\Goodby\Interpreter->interpret(Array)
#16 ./src/Import/Adapter/Json.php(128): TechDivision\Import\Adapter\Goodby\Lexer->parse('/Users/user...', Object(TechDivision\Import\Adapter\Goodby\Interpreter))
#17 ./vendor/techdivision/import/src/Subjects/AbstractSubject.php(835): Central\Leia\Import\Adapter\Json->import(Array, '/Users/user...')
#18 ./vendor/techdivision/import/src/Subjects/SubjectExecutor.php(131): TechDivision\Import\Subjects\AbstractSubject->import('9b13b7f056652f2...', '/Users/user...')
#19 ./vendor/techdivision/import/src/Plugins/SubjectPlugin.php(168): TechDivision\Import\Subjects\SubjectExecutor->execute(Object(TechDivision\Import\Configuration\Jms\Configuration\Subject), Array, '9b13b7f056652f2...', '/Users/user...')
#20 ./vendor/techdivision/import/src/Plugins/SubjectPlugin.php(120): TechDivision\Import\Plugins\SubjectPlugin->processSubject(Object(TechDivision\Import\Configuration\Jms\Configuration\Subject))
#21 ./vendor/techdivision/import/src/Plugins/PluginExecutor.php(117): TechDivision\Import\Plugins\SubjectPlugin->process()
#22 ./vendor/techdivision/import/src/Modules/PluginModule.php(144): TechDivision\Import\Plugins\PluginExecutor->execute(Object(TechDivision\Import\Configuration\Jms\Configuration\Plugin))
#23 ./src/Import/Application.php(400): TechDivision\Import\Modules\PluginModule->process()
#24 ./src/Leia.php(65): Central\Leia\Import\Application->process('9b13b7f056652f2...')
#25 ./app/Controller/V1/ProductController.php(108): Central\Leia\Leia->import('[\n {\n "sku": "...', 'json')
#26 ./vendor/symfony/http-kernel/HttpKernel.php(145): App\Controller\V1\ProductController->import(Object(Symfony\Component\HttpFoundation\Request), Object(Central\Leia\Leia))
#27 ./vendor/symfony/http-kernel/HttpKernel.php(67): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#28 ./vendor/symfony/http-kernel/Kernel.php(191): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 ./public/index.php(25): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#30 {main}
Next PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento2`.`catalog_product_entity_varchar`, CONSTRAINT `CAT_PRD_ENTT_VCHR_ROW_ID_CAT_PRD_ENTT_ROW_ID` FOREIGN KEY (`row_id`) REFERENCES `catalog_product_entity` (`row_id`) ON DELETE CASCADE) when executing SQL "INSERT
INTO catalog_product_entity_varchar
(row_id,
attribute_id,
store_id,
value)
VALUES (356272,
73,
1,
test_1 LIjh jIJb ALJ A DJhDDL)" in ./vendor/techdivision/import/src/Actions/Processors/AbstractBaseProcessor.php:180
Stack trace:
#0 ./vendor/techdivision/import-product/src/Actions/Processors/ProductVarcharCreateProcessor.php(64): TechDivision\Import\Actions\Processors\AbstractBaseProcessor->execute(Array, NULL)
#1 ./vendor/techdivision/import/src/Actions/GenericIdentifierAction.php(67): TechDivision\Import\Product\Actions\Processors\ProductVarcharCreateProcessor->execute(Array, NULL, 'value_id')
#2 ./vendor/techdivision/import/src/Actions/GenericIdentifierAction.php(54): TechDivision\Import\Actions\GenericIdentifierAction->create(Array, NULL)
#3 ./vendor/techdivision/import-product/src/Services/ProductBunchProcessor.php(1055): TechDivision\Import\Actions\GenericIdentifierAction->persist(Array, NULL)
#4 ./vendor/techdivision/import-product/src/Observers/ProductAttributeObserver.php(199): TechDivision\Import\Product\Services\ProductBunchProcessor->persistProductVarcharAttribute(Array)
#5 ./vendor/techdivision/import/src/Observers/AttributeObserverTrait.php(282): TechDivision\Import\Product\Observers\ProductAttributeObserver->persistVarcharAttribute(Array)
#6 ./vendor/techdivision/import/src/Observers/AbstractAttributeObserver.php(60): TechDivision\Import\Product\Ee\Observers\EeProductAttributeUpdateObserver->process()
#7 ./vendor/techdivision/import/src/Observers/GenericCompositeObserver.php(117): TechDivision\Import\Observers\AbstractAttributeObserver->handle(Object(TechDivision\Import\Product\Ee\Subjects\EeBunchSubject))
#8 ./vendor/techdivision/import/src/Subjects/AbstractSubject.php(986): TechDivision\Import\Observers\GenericCompositeObserver->handle(Object(TechDivision\Import\Product\Ee\Subjects\EeBunchSubject))
#9 ./src/Import/Adapter/Json.php(120): TechDivision\Import\Subjects\AbstractSubject->importRow(Array)
#10 [internal function]: Central\Leia\Import\Adapter\Json->Central\Leia\Import\Adapter\{closure}(Array)
#11 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(149): call_user_func(Object(Closure), Array)
#12 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(135): TechDivision\Import\Adapter\Goodby\Interpreter->delegate(Object(Closure), Array)
#13 ./vendor/techdivision/import/src/Adapter/Goodby/Interpreter.php(74): TechDivision\Import\Adapter\Goodby\Interpreter->notify(Array)
#14 ./vendor/techdivision/import/src/Adapter/Goodby/Lexer.php(120): TechDivision\Import\Adapter\Goodby\Interpreter->interpret(Array)
#15 ./src/Import/Adapter/Json.php(128): TechDivision\Import\Adapter\Goodby\Lexer->parse('/Users/user...', Object(TechDivision\Import\Adapter\Goodby\Interpreter))
#16 ./vendor/techdivision/import/src/Subjects/AbstractSubject.php(835): Central\Leia\Import\Adapter\Json->import(Array, '/Users/user...')
#17 ./vendor/techdivision/import/src/Subjects/SubjectExecutor.php(131): TechDivision\Import\Subjects\AbstractSubject->import('9b13b7f056652f2...', '/Users/user...')
#18 ./vendor/techdivision/import/src/Plugins/SubjectPlugin.php(168): TechDivision\Import\Subjects\SubjectExecutor->execute(Object(TechDivision\Import\Configuration\Jms\Configuration\Subject), Array, '9b13b7f056652f2...', '/Users/user...')
#19 ./vendor/techdivision/import/src/Plugins/SubjectPlugin.php(120): TechDivision\Import\Plugins\SubjectPlugin->processSubject(Object(TechDivision\Import\Configuration\Jms\Configuration\Subject))
#20 ./vendor/techdivision/import/src/Plugins/PluginExecutor.php(117): TechDivision\Import\Plugins\SubjectPlugin->process()
#21 ./vendor/techdivision/import/src/Modules/PluginModule.php(144): TechDivision\Import\Plugins\PluginExecutor->execute(Object(TechDivision\Import\Configuration\Jms\Configuration\Plugin))
#22 ./src/Import/Application.php(400): TechDivision\Import\Modules\PluginModule->process()
database already has sku test_1
:
entity_id sku row_id
356272 test_1 356271
ps: database does not have any data with entity_id = 356271
, and if it was there, m2if would have mapped the attribute name with entity_id 356271
instead of 356272
(356272 = sku test_1)
@adhocore I'll test this as soon as possible and come back to you.
alright thanks
further finding, which may help you:
EeAttributeObserverTrait::getPrimaryKey()
calls $this->getSubject()->getLastRowId()
but the getLastRowId()
gives back entity_id instead of row_id
by default it seems to work only when row_id and entity_id is same for a given sku
in case they are different, then there will be error in sql layer (integrity constraint violation).