I've recently started learning about creating EAV models. It's been quite the ride so far. Although I feel I'm very close right now.
Currently I have created a "Vendor" EAV Model, but when I try to save the model it throws an SQL 1452 Error:
SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`dh_onsite_vendor_entity`, CONSTRAINT `FK_DH_ONSITE_VENDOR_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_), query was: INSERT INTO `dh_onsite_vendor_entity` (`entity_type_id`, `created_at`, `updated_at`) VALUES (?, '2017-01-17 21:40:04', '2017-01-17 21:40:04')
What I've found to be the problem is that Magento isn't automatically adding the correct values into
Here is code that throws the error:
$test = Mage::getModel('onsite/vendor'); $test->setLabel('Hello World'); $test->save();
Here is code that doesn't throw the error:
$test = Mage::getModel('onsite/vendor'); $test->setLabel('Hello World'); $test->setAttributeSetId(9); $test->setEntityId(10); $test->save();
I realized this because I was able to create a record by setting this myself.
Please let me know if you need anymore information from me.