Skip to content

Commit adcb028

Browse files
author
Mohan Ahuja
committed
ACP2E-998: Order Increment Id not generated with the prefix
- Added code to update sales sequence profile with prefix, so that orders are creating with defined prefix in installation script.
1 parent d379b7f commit adcb028

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,29 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
12961296
];
12971297
$dbConnection->insert($setup->getTable('eav_entity_store'), $rowData);
12981298
}
1299+
1300+
// Get meta id for adding in profile table for order prefix
1301+
$selectMeta = $dbConnection->select()
1302+
->from($setup->getTable('sales_sequence_meta'), 'meta_id')
1303+
->where('entity_type = \'order\'')
1304+
->where('store_id = \'' . Store::DISTRO_STORE_ID . '\'');
1305+
$metaId = $dbConnection->fetchOne($selectMeta);
1306+
1307+
// See if row already exists
1308+
$incrementRow = $dbConnection->fetchRow(
1309+
'SELECT * FROM ' . $setup->getTable('sales_sequence_profile') . ' WHERE meta_id = ?',
1310+
[$metaId]
1311+
);
1312+
1313+
if (!empty($incrementRow)) {
1314+
// Row exists, update it
1315+
$profileId = $incrementRow['profile_id'];
1316+
$dbConnection->update(
1317+
$setup->getTable('sales_sequence_profile'),
1318+
['prefix' => $orderIncrementPrefix, 'is_active' => '1'],
1319+
'profile_id = ' . $profileId
1320+
);
1321+
}
12991322
}
13001323

13011324
/**

0 commit comments

Comments
 (0)