Increment.php 657 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\Entity\Attribute\Backend;
  7. /**
  8. * Entity/Attribute/Model - attribute backend default
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Increment extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
  14. {
  15. /**
  16. * Set new increment id
  17. *
  18. * @param \Magento\Framework\DataObject $object
  19. * @return $this
  20. */
  21. public function beforeSave($object)
  22. {
  23. if (!$object->getId()) {
  24. $this->getAttribute()->getEntity()->setNewIncrementId($object);
  25. }
  26. return $this;
  27. }
  28. }