/** * {@inheritdoc} */ protected function prepareDataForUpdate($object) { $data = parent::prepareDataForUpdate($object); if (isset($data['updated_at'])) { unset($data['updated_at']); } return $data; }
/** * Perform actions after object delete * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object) { parent::_afterDelete($object); return $this; }
/** * Prepare data before save * * @param \Magento\Framework\Model\AbstractModel $group * @return $this */ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $group) { /** @var \Magento\Customer\Model\Group $group */ $group->setCode(substr($group->getCode(), 0, $group::GROUP_CODE_MAX_LENGTH)); return parent::_beforeSave($group); }
/** * {@inheritdoc} */ public function save(\Magento\Framework\Model\AbstractModel $object) { if (!$object->isPreventSaving()) { return parent::save($object); } }
/** * Save status labels per store * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { if ($object->hasStoreLabels()) { $labels = $object->getStoreLabels(); $this->getConnection()->delete($this->labelsTable, ['status = ?' => $object->getStatus()]); $data = []; foreach ($labels as $storeId => $label) { if (empty($label)) { continue; } $data[] = ['status' => $object->getStatus(), 'store_id' => $storeId, 'label' => $label]; } if (!empty($data)) { $this->getConnection()->insertMultiple($this->labelsTable, $data); } } return parent::_afterSave($object); }