Feed Me import gives SQL error despite not importing into any ansel field
Try out Ansel version 1.0.7 beta 1 and see if if fixes the issue. See comment below for further details.
Random products in the import feed gives
CDbCommand failed to execute the SQL statement: SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mandaomm_craft_tenotec
FOREIGN KEY (originalAssetId
) ON DELETE SET NULL)
I’m positive that the feed isn’t set to import images into any ansel fields, and I’ve validated the feed for errors as well (JSON).
I don’t understand why ansel is even triggered. Any ideas?
Much appreciated, cheers!
Sorry, this is the correct error:
Ansel dependency injection error: Injected dependency "userModel" does not match expected type "\Craft\UserModel" in class BuzzingPixel\Ansel\Service\AnselImages\SaveRowService
November 1, 2017, 12:06 pm
If an element has an Ansel field attached to it, Ansel will always run even if there is no data.
Per our conversation on Slack, I suspect that the issue that the import is essentially running “headless” meaning there is no user. There is an assumption of a user for Ansel in that each image row requires a user ID. I have attached a beta build of Ansel in which I have updated my dependency injection to get the first admin user it can find if a user is not defined on the session. That should hopefully fix the issue. Can you let me know how it goes?
November 1, 2017, 12:48 pm
Hey, unfortunately the problem persists (same error message).
November 1, 2017, 2:49 pm
anselDi.php line 193 where you see
$userModel = $app->userSession->getUser();, can you add the following and let me know what the output is?
$userModel = $app->userSession->getUser(); echo '<pre>; var_dump($userModel); die;
November 1, 2017, 2:53 pm
Sure thing. I’ve PM’ed you the output on slack, as it’s quite long.
November 1, 2017, 3:47 pm
Well, that’s befuddling. It’s a valid
November 2, 2017, 5:09 pm
Good news, it works (almost) now. I just noticed a newer version of Feed Me (I was sure I had the last one, sorry), and I’m not sure if it’s that, you, the combo or what, but out of 926 products in the json file, i’m getting
Products (NO): Commerce_Product 4478 updated. on almost all of them.
A (very) few are still causing the import to fail, giving
Products (NO): CDbCommand failed to execute the SQL statement: SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mandaomm_craft_tenotec`.`craft_anselImages`, CONSTRAINT `craft_anselImages_originalAssetId_fk` FOREIGN KEY (`originalAssetId`) REFERENCES `craft_assetfiles` (`id`) ON DELETE SET NULL)
Any idea on that one?
November 3, 2017, 5:38 pm
It looks like Ansel is trying to insert a row into the anselImages table but there’s no Asset with the ID Ansel is trying to insert.
November 3, 2017, 5:40 pm
So in other words the json could be refering to an image that doesn’t exist on the server?
November 3, 2017, 5:49 pm
An image that doesn’t exist in the database, but yes. It’s a MySQL foreign key constraint.
It is odd since, as you mentioned, the feed isn’t supposed to be importing any images into an Ansel field. I’d be curious what data Feed Me is sending to the Ansel field.
November 3, 2017, 5:54 pm
The fix with for
Ansel dependency injection error isn’t working after all
November 9, 2017, 7:54 am
Log In or Register to Comment
Your account with the old support system does not carry over to the new support system. The new system is all tied together and connected with your account for purchasing and licenses. If you have a license, you have an account and you can log in with that email address and password. If you have not set a new password yet, you can do so with the forgot password link. Very sorry for any inconvenience.