Magento Certified Developer GuideCategory: 5. EAVHow does the model distinguish between insert and update operations?
Manish Prakash Staff asked 5 years ago

When we save an EAV entity, the model checks if the entity id is present in the base table of entity. If its present the update operations occurs, else insert operation.
In class “Mage_Eav_Core_Model_Entity_Abstract” there is a function “_processSaveData()”

        if (!empty($entityId) && is_numeric($entityId)) {
            $bind   = array('entity_id' => $entityId);
            $select = $adapter->select()
                ->from($entityTable, $entityIdField)
                ->where("{$entityIdField} = :entity_id");
            $result = $adapter->fetchOne($select, $bind);
            if ($result) {
                $insertEntity = false;
            }
        }

Here there is a check for insert or update. For attribute there is no distinction as such, during insert/update all operations for attribute are performed (insert,update,delete)