Ejemplo n.º 1
0
 /**
  * Perform actions before object save
  * Perform actions before object save, calculate next sequence value for increment Id
  *
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\AbstractModel $object */
     if ($object instanceof EntityInterface && $object->getIncrementId() == null) {
         $object->setIncrementId($this->sequenceManager->getSequence($object->getEntityType(), $object->getStore()->getGroup()->getDefaultStoreId())->getNextValue());
     }
     parent::_beforeSave($object);
     return $this;
 }
Ejemplo n.º 2
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);
 }