BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Skip update specific field on some condition #55

Closed betterapp closed 1 year ago

betterapp commented 1 year ago

In documentation there is only information about skipping all Item update by return null in one of Key field.

But I need to skip update some specific field os some conditions but the rest I need to update.

As I see if I return "false" from field settings the field is not updated. This works for relation field. But how can I skip update other field type - for example boolean, or text ?

Is it possible ?

BlackbitDevs commented 1 year ago

Yes, this is possible: You can return $params['currentValue'] in the field's callback function when you want to keep the current value, e.g.

if(strlen($params['value']) > strlen($params['currentValue']) {
  return $params['value'];
} else {
  return $params['currentValue'];
}
betterapp commented 1 year ago

Working - thanks