Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function prepareDataForUpdate($object)
 {
     $data = parent::prepareDataForUpdate($object);
     if (isset($data['updated_at'])) {
         unset($data['updated_at']);
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function save(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->isPreventSaving()) {
         return parent::save($object);
     }
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * 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);
 }