Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting the Change Increment ID KB to devdocs #5129

Merged
merged 15 commits into from
Aug 15, 2019
5 changes: 4 additions & 1 deletion _data/toc/configuration-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ pages:
url: /config-guide/multi-site/ms_over.html
children:

- label: Change increment ID for a database entity on particular store
url: /config-guide/multi-site/change-increment-id.html

- label: Set up multiple websites, stores, and store views in the Admin
url: /config-guide/multi-site/ms_websites.html

Expand Down Expand Up @@ -423,4 +426,4 @@ pages:
url: /architecture/gdpr/magento-2x.html

- label: Magento 1.x
url: /architecture/gdpr/magento-1x.html
url: /architecture/gdpr/magento-1x.html
84 changes: 84 additions & 0 deletions guides/v2.2/config-guide/multi-site/change-increment-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
group: configuration-guide
title: Change increment ID for a database entity on particular store
functional_areas:
- Configuration
- System
- Setup
---

This article discusses how to change the increment ID for a Magento database (DB) entity (order, invoice, credit memo, etc.) on a particular Magento store using the `ALTER TABLE` SQL statement.

## Affected versions

- Magento Commerce (on premise): 2.x.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- Magento Commerce (Cloud): 2.x.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce (Cloud) with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted.

- MySQL: any supported version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a link to the topic that lists the supported versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.


## When would you need to change increment ID

You might need to change the increment ID for new DB entities in these cases:

- After a hard backup restore on a Live site
- Some order records have been lost, but their IDs are already being used by payment gateways (like PayPal) for your current Merchant account. Such being the case, the payment gateways stop processing new orders that have the same IDs, returning the "Duplicate invoice id" error

{: .bs-callout-info}
You may also fix the payment gateway issue for PayPal by allowing multiple payments per invoice ID in PayPal's Payment Receiving Preferences. See the Knowledge Base article: [PayPal gateway rejected request - duplicate invoice issue][] .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You may also fix the payment gateway issue for PayPal by allowing multiple payments per invoice ID in PayPal's Payment Receiving Preferences. See the Knowledge Base article: [PayPal gateway rejected request - duplicate invoice issue][] .
You may also fix the payment gateway issue for PayPal by allowing multiple payments per invoice ID in PayPal's Payment Receiving Preferences. See [PayPal gateway rejected request - duplicate invoice issue][] in the _Knowledge Base_.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!


## Prerequisite steps

1. Find stores and entities for which the new increment ID should be changed.
1. Connect to your MySQL DB.
For Magento Commerce (Cloud), at first, you need to SSH to your environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable for Magento Commerce cloud is {{site.data.var.ece}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

1. Check the current auto_increment value for the entity sequence table using the following query:

```sql
SHOW TABLE STATUS FROM `{database_name}` WHERE `name` LIKE 'sequence_{entity_type}_{store_id}';
```

## Example

If you are checking an auto increment for an order on the store with ID=1, the table name would be 'sequence_order_1'.

If the value of the `auto_increment` column is '1234', the next order placed at the store with `ID=1` will have the ID '#100001234'.

## Update entity to change increment ID

Update the entity using the following query:

```sql
ALTER TABLE sequence_{entity_type}_{store_id} AUTO_INCREMENT = {new_increment_value};
```

{: .bs-callout-info}
Important: The new increment value must be greater than the current one, not less.

## Example

After executing the following query:

```sql
ALTER TABLE sequence_order_1 AUTO_INCREMENT = 2000;
```

The next order placed at the store with `ID=1` will have the ID '#100002000'.

## Additional recommended steps on production environments (cloud)

Before executing the `ALTER TABLE` query on a production environment of Magento Commerce (Cloud), we strongly recommend performing these steps:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable for cloud...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup


- Test the entire procedure of changing the increment ID on your Staging environment
- [Create a DB backup][] to restore your Production DB in case of failure

## Related documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boo...these related sections are draining and prone to URL maintenance. I would work links in to the content where it is relevant, or remove them completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are ok.


- [Set up a remote MySQL database connection][]
- [Create database dump on Cloud][]
- [SSH to your environment][]

<!-- Link Definitions -->
[PayPal gateway rejected request - duplicate invoice issue]: https://support.magento.com/hc/en-us/articles/115002457473
[Set up a remote MySQL database connection]: {{ page.baseurl }}/install-gde/prereq/mysql_remote.html
[Create a DB backup]: https://support.magento.com/hc/en-us/articles/360003254334
[Create database dump on Cloud]: https://support.magento.com/hc/en-us/articles/360003254334
[SSH to your environment]: {{ page.baseurl }}/cloud/env/environments-ssh.html#ssh
84 changes: 84 additions & 0 deletions guides/v2.3/config-guide/multi-site/change-increment-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
group: configuration-guide
title: Change increment ID for a database entity on particular store
functional_areas:
- Configuration
- System
- Setup
---

This article discusses how to change the increment ID for a Magento database (DB) entity (order, invoice, credit memo, etc.) on a particular Magento store using the `ALTER TABLE` SQL statement.

## Affected versions

- Magento Commerce (on premise): 2.x.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

- Magento Commerce (Cloud): 2.x.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce (Cloud) with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- MySQL: any supported version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a link to the topic and section that lists supported versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


## When would you need to change increment ID

You might need to change the increment ID for new DB entities in these cases:

- After a hard backup restore on a Live site
- Some order records have been lost, but their IDs are already being used by payment gateways (like PayPal) for your current Merchant account. Such being the case, the payment gateways stop processing new orders that have the same IDs, returning the "Duplicate invoice id" error

{: .bs-callout-info}
You may also fix the payment gateway issue for PayPal by allowing multiple payments per invoice ID in PayPal's Payment Receiving Preferences. See the Knowledge Base article: [PayPal gateway rejected request - duplicate invoice issue][] .

## Prerequisite steps

1. Find stores and entities for which the new increment ID should be changed.
1. Connect to your MySQL DB.
For Magento Commerce (Cloud), at first, you need to SSH to your environment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to SSH -> to connect using SSH

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce (Cloud) with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dun and Dun

1. Check the current auto_increment value for the entity sequence table using the following query:

```sql
SHOW TABLE STATUS FROM `{database_name}` WHERE `name` LIKE 'sequence_{entity_type}_{store_id}';
```

## Example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two Example sections of the same highest level in the topic. This doesn't seem right. I assume that they should be converted to subsections, or be more verbose than just Example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed them.


If you are checking an auto increment for an order on the store with ID=1, the table name would be 'sequence_order_1'.

If the value of the `auto_increment` column is '1234', the next order placed at the store with `ID=1` will have the ID '#100001234'.

## Update entity to change increment ID

Update the entity using the following query:

```sql
ALTER TABLE sequence_{entity_type}_{store_id} AUTO_INCREMENT = {new_increment_value};
```

{: .bs-callout-info}
Important: The new increment value must be greater than the current one, not less.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove , not less

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


## Example

After executing the following query:

```sql
ALTER TABLE sequence_order_1 AUTO_INCREMENT = 2000;
```

The next order placed at the store with `ID=1` will have the ID '#100002000'.

## Additional recommended steps on production environments (cloud)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud -> Cloud

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use cloud in parenthesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nobody puts baby in the corner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😜


Before executing the `ALTER TABLE` query on a production environment of Magento Commerce (Cloud), we strongly recommend performing these steps:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Magento Commerce (Cloud) with a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


- Test the entire procedure of changing the increment ID on your Staging environment
- [Create a DB backup][] to restore your Production DB in case of failure

## Related documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it.


- [Set up a remote MySQL database connection][]
- [Create database dump on Cloud][]
- [SSH to your environment][]

<!-- Link Definitions -->
[PayPal gateway rejected request - duplicate invoice issue]: https://support.magento.com/hc/en-us/articles/115002457473
[Set up a remote MySQL database connection]: {{ page.baseurl }}/install-gde/prereq/mysql_remote.html
[Create a DB backup]: https://support.magento.com/hc/en-us/articles/360003254334
[Create database dump on Cloud]: https://support.magento.com/hc/en-us/articles/360003254334
[SSH to your environment]: {{ page.baseurl }}/cloud/env/environments-ssh.html#ssh