Some information good to know:
The method Magento\SalesSequence\Model\Sequence->getNextValue() crashes.
It looks like this:
public function getNextValue()
{
$this->connection->insert($this->meta->getSequenceTable(), []);
$this->lastIncrementId = $this->connection->lastInsertId($this->meta->getSequenceTable());
return $this->getCurrentValue();
}
$this->meta->getSequenceTable() returns NULL, causing the adapter to do the following:
INSERT INTO `` () VALUES ()
This obviously doesn't work, thus the whole order creation crashes.
What could possibly cause $this->meta->getSequenceTable() to return NULL?
@Desmaster : That issue because have some new work flow of sales module in Magento 2.
and your database migrated is multiple stores
and it's missing needed tables for module-sales and module-sales-sequence.
You can see more at this: http://i.imgur.com/rkFvbC8.png
=> That are initial tables after you install a fresh Magento 2.
and after migrate data with this tool, you database was missing some tables for other stores (not default store)
See more: https://mage2.pro/t/topic/511
Regards
Mall.
Completely agree here
in my opinion it is dangerous that \Magento\SalesSequence\Model\Sequence::getNextValue() is
relaying on $this->meta->getSequenceTable() being always populated.
\Magento\SalesSequence\Model\ResourceModel\Meta::loadByEntityTypeAndStore() is feeding data to \Magento\SalesSequence\Model\Manager
getSequence() method should throw Exception if meta is not found
MAGETWO-52506
Sorry for late reply. I assume you did not migrate settings before data migration
php bin/magento migrate:settings
@victor-v-rad - no I didn't migrate settings - is there any reference in the settings migration to recreate sequence tables?
When you migrate settings you migrate stores and websites. Skipping this probably causes the issue with sequence tables. Please stick close to the official documentation
@victor-v-rad thanks for the tip, I will try that and check
I was looking in the code and the Settings Step actually is copying data between core_config_data tables only - unless I miss something obvious
https://github.com/magento/data-migration-tool/blob/master/src/Migration/Step/Settings/Data.php
See in
https://github.com/magento/data-migration-tool/blob/master/etc/ce-to-ce/1.9.2.3/config.xml.dist
Settings mode consist of Settings Step and Stores Step
Thanks for pointing that, Settings mode consists of two steps - settings and stores
So actual task is here - https://github.com/magento/data-migration-tool/blob/master/src/Migration/Step/Stores/Data.php#L66
But again - this is just simple data copy between 3 tables hardcoded in helper
https://github.com/magento/data-migration-tool/blob/master/src/Migration/Step/Stores/Helper.php
Still don't see how sequence tables will be created by this step
@victor-v-rad please advice
Sequence tables are created here \Migration\Step\SalesIncrement\Data::createSequenceTable
@victor-v-rad thanks - that's fine, but what if someone is not actually want to migrate orders?
Looks like there should be some dependencies betweens modes/steps
What do you think?
Dependencies exist. You cannot migrate only orders by the tool out of the box
@victor-v-rad I think you mean opposite - that you need to migrate orders always to make sure that sequence tables are generated
I got this bug without any "migrate" operations. I just created second store for tutorial tasks and this bug occured.
please use one of the following:
php
$this->_eventManager->dispatch('store_add', ['store' => $storeModel]);
where $storeModel is your \Magento\Store\Model\Store which has been saved now.
This only works if you create store view for the first time.
php
foreach ($this->entityPool->getEntities() as $entityType) {
$this->sequenceBuilder->setPrefix($storeId)
->setSuffix($this->sequenceConfig->get('suffix'))
->setStartValue($this->sequenceConfig->get('startValue'))
->setStoreId($storeId)
->setStep($this->sequenceConfig->get('step'))
->setWarningValue($this->sequenceConfig->get('warningValue'))
->setMaxValue($this->sequenceConfig->get('maxValue'))
->setEntityType($entityType)
->create();
}
where $storeId is the id of your newly created store view.
This is also useful if you have already created your store views and want to fix them.
All required DIs can be found in the file mentioned above.
@victor-v-rad my development database does not have any orders in it due to PCI complaince. The sequence tables for stores > 1 are never created.
Hi @tdgroot the issued has been fixed in 2.1.8. Please, let us know if you still have the issue
Most helpful comment
I got this bug without any "migrate" operations. I just created second store for tutorial tasks and this bug occured.