public function testGetSequence() { $entityType = 'order'; $storeId = 1; $this->resourceSequenceMeta->expects($this->once())->method('loadByEntityTypeAndStore')->with($entityType, $storeId)->willReturn($this->meta); $this->sequenceFactory->expects($this->once())->method('create')->with(['meta' => $this->meta])->willReturn($this->sequence); $this->assertSame($this->sequence, $this->sequenceManager->getSequence($entityType, $storeId)); }
/** * 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; }
/** * Get reserved order id * * @param \Magento\Quote\Model\Quote $quote * @return string */ public function getReservedOrderId($quote) { return $this->sequenceManager->getSequence(\Magento\Sales\Model\Order::ENTITY, $quote->getStore()->getGroup()->getDefaultStoreId())->getNextValue(); }