Skip to content

Commit e73b4f2

Browse files
author
Mohan Ahuja
committed
ACP2E-998: Order Increment Id not generated with the prefix
- Updated raw query with parameterized query as per CR comments
1 parent adcb028 commit e73b4f2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class Installer
9191

9292
public const INFO_MESSAGE = 'message';
9393

94+
public const ENTITY_TYPE_ORDER = 'order';
95+
9496
/**
9597
* The lowest supported MySQL verion
9698
*/
@@ -1270,14 +1272,15 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
12701272
// get entity_type_id for order
12711273
$select = $dbConnection->select()
12721274
->from($setup->getTable('eav_entity_type'), 'entity_type_id')
1273-
->where('entity_type_code = \'order\'');
1275+
->where('entity_type_code = ?', self::ENTITY_TYPE_ORDER);
12741276
$entityTypeId = $dbConnection->fetchOne($select);
12751277

12761278
// See if row already exists
1277-
$incrementRow = $dbConnection->fetchRow(
1278-
'SELECT * FROM ' . $setup->getTable('eav_entity_store') . ' WHERE entity_type_id = ? AND store_id = ?',
1279-
[$entityTypeId, Store::DISTRO_STORE_ID]
1280-
);
1279+
$eavEntityStore = $dbConnection->select()
1280+
->from($setup->getTable('eav_entity_store'))
1281+
->where('entity_type_id = ?', $entityTypeId)
1282+
->where('store_id = ?', Store::DISTRO_STORE_ID);
1283+
$incrementRow = $dbConnection->fetchRow($eavEntityStore);
12811284

12821285
if (!empty($incrementRow)) {
12831286
// row exists, update it
@@ -1300,23 +1303,22 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
13001303
// Get meta id for adding in profile table for order prefix
13011304
$selectMeta = $dbConnection->select()
13021305
->from($setup->getTable('sales_sequence_meta'), 'meta_id')
1303-
->where('entity_type = \'order\'')
1304-
->where('store_id = \'' . Store::DISTRO_STORE_ID . '\'');
1306+
->where('entity_type = ?', self::ENTITY_TYPE_ORDER)
1307+
->where('store_id = ?', Store::DISTRO_STORE_ID);
13051308
$metaId = $dbConnection->fetchOne($selectMeta);
13061309

13071310
// See if row already exists
1308-
$incrementRow = $dbConnection->fetchRow(
1309-
'SELECT * FROM ' . $setup->getTable('sales_sequence_profile') . ' WHERE meta_id = ?',
1310-
[$metaId]
1311-
);
1311+
$profile = $dbConnection->select()
1312+
->from($setup->getTable('sales_sequence_profile'))
1313+
->where('meta_id = ?', $metaId);
1314+
$incrementRow = $dbConnection->fetchRow($profile);
13121315

13131316
if (!empty($incrementRow)) {
13141317
// Row exists, update it
1315-
$profileId = $incrementRow['profile_id'];
13161318
$dbConnection->update(
13171319
$setup->getTable('sales_sequence_profile'),
13181320
['prefix' => $orderIncrementPrefix, 'is_active' => '1'],
1319-
'profile_id = ' . $profileId
1321+
'profile_id = ' . $incrementRow['profile_id']
13201322
);
13211323
}
13221324
}

0 commit comments

Comments
 (0)