In Magento 2.2.6 they "fixed" an error, all invoices had the sequence number of the default store. This worked out for us because we need the invoices for all storeviews in a single sequence for Tax purposes.
The change was made in the file magento\module-sales\Model\ResourceModel\EntityAbstract.php
Now I want to revert this change without altering the Core Code. The code I want to use is: (From Magento 2.2.5)
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;
}
Now I tried Various options using my own Module with preference setting is the di.xml but I can get it to work. Magento only uses the original code and not the one I want it to use.
For Now I changed the Magento 2 Core Code but this is not the right way.
Any thoughts on this? I'm really stuck.