I use Craft CMS 4.2.5.2. I have a simple question, but I can't find an answer to it. I have a module. In it, I wrote a controller that runs through all the elements of the section and performs some actions on each element of the section. I need a condition with which I can check the element field for emptiness. I wrote this:
$entries = Entry::find()->section('products');
foreach($entries as $entry){
if ($entry->getFieldValue('productApiId')){
echo "field not empty<br />";
}else{
echo "field empty<br />";
}
}
But this design does not work. If the field is empty, the message "field empty" is not displayed. Tell me please.