Bulk Update Customizable Product Options in Magento2

Today I had to bulk-update the Price and Max Characters in the tab Customizable Options for hundreds of simple products based on the title.

Magento2 Customizable Product Option

I knew that it could be done programmatically but I figured out that it can be done just by updating the table catalog_product_option and catalog_product_option_price. First I got a comma separated list of option_id’s based on a specific title.

With the comma separated list I was able to update the value of the Price and Max Characters as follows.

1. Price

2. Max Characters

Possible that you have to flush the cache ( php/magento cache:flush ) and re-index everything ( php/magento indexer:reindex ) to see the results.

Category “Default Category/abc/def/” has not been created. URL key for specified store already exists in Magento2

A new day, a new problem. While importing new products in Magento 2.1.2 via System > Data Transfer > Import something was causing the following error message.

The CSV file was 100% correct, which was making it difficult to figure out why it is causing the error. I ran few more test imports and noticed that the main category actually had an empty space at the end, which I believe was causing the whole problem.

Magento2 Category Name Empty Space

The import ran through without any errors after removing the empty space. However, before I also removed all related URL rewrites as follows. Not sure if this was actually necessary.

After that I rebuilt the re-write table with https://github.com/olegkoval/magento2-regenerate_url_rewrites because for some reason the importer didn’t create the rewrite URLs.

After that everything was working as expected.

Change Order, Invoice, Credit Memo or Shipment Number Prefix or Suffix in Magento2

In some cases shop owners have to change their default order number with a custom prefix or suffix. Customising order numbers sounds complicated, but it can be done with only few MySQL queries.

First, backup your database. After that, get a list of meta_id’s and store_id’s with the following query for order numbers only.

The meta_id is pretty much the identifier you need for the next UPDATE query which will add the letter A as a prefix. For example: A100000001

The same query can be used to change the suffix. Also, you can change the prefix or suffix for any entity_type such as invoice, creditmemo or shipment.

That’s it. Create a new order to see the results.