protected function _getLastInsertedId()
    {
        $objectId = null;
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);

        $tableName = $this->getObject()->getCoreTableName();
        $query = 'SELECT OXID FROM '. $tableName .' ORDER BY OXTIMESTAMP DESC LIMIT 1';
        $result = $oDb->select($query);

        if ($result != false && $result->count() > 0) {
            $fields = $result->fields;
            $objectId = $fields['OXID'];
        }

        return $objectId;
    }