How To Find Out If A Record Already Exists In A Database Or Not In Magento?

How To Find Out If A Record Already Exists In A Database Or Not In Magento?

To Check Out Whether Record Exists In The Database Of Magento You Can Use The Following Query:::

getCollection()->addFieldToFilter('field_name', $value_to_check)->getFirstItem();
if($collection->getId()){
   // if record found in database
}else{
    if record not found in database
}

?>

Above if else condition checks if the record exists in database or not.

That's it!

Read the guidelines for Technology + Write For Us + Guest Post Category and send blog at developergang1@gmail.com