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.

Create Static Block via SQL Queries in Magento2

Today I had to create a static block quickly via SQL queries because for some reason the grid in Content > Blocks didn’t work. First I created the static block itself.

Values for fields creation_time, update_time and is_active are not required because MySQL will add default values.

After that I created the relation between static block and the actual store.

In order to get the correct block_id you simply have to get block_id from the table cms_block.

In my case the block_id of my new static block was 32. That’s it.

Class not found in AbstractFactory

Today I had some trouble with removing a module on Magento2 and its custom product attributes. After removing the code of Mageplaza_Seo I was not able to edit products, categories or even checkout anymore.

The reason was an attribute called mp_meta_robots which was still pointing to the class \Mageplaza\Seo\Model\Source\Robots. I found the attribute by checking the table eav_attribute as follows.

Removing this via backend or MySQL has fixed the problem.

Update Order Status With SQL Queries in Magento2

Today I had to update order numbers which were processed already, but not updated in Magento. Here is how I changed the order status directly in the database based on the increment_id.

The first query will update the state and status on the table sales_order.

The second one will update the status in the grid view in Sales > Orders.

Cannot gather stats! Warning!stat(): stat failed

Today I imported a couple of new products with uRapidFlow in Magento 2.1.2. I ran the import with the option Action on missing image file which was set to WARNING and update image field. It worked fine, but I accidentally forgot to upload the product images.

So basically uRapidFlow added non-existing product images to the database which broke the product edit form in the admin panel.

The temporarily solution was to manipulate ./vendor/magento/module-catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php in vendor around line 142,143.

I basically added is_readable to check if the file exists. Not great, but at least I was able to edit products again and proceed with a permanent fix.

Related issues:
https://github.com/magento/magento2/issues/5497

Algolia and Undefined index: store_id

Today I have setup the Algolia Queue Runner ( algolia_queue_runner ) which was working fine for all projects I have worked with before. However, today it was different. The Algolia Queue Runner didn’t work at all. Here is what happened every time when the cronjob was running.

The problem was, one of the store views in Stores > Settings > All Stores was disabled for some reason. After enabling the store view, the problem was fixed.

Delete Quote For Specific Customer In Magento2

Sometimes a quote can be linked with product id’s which doesn’t exists anymore. In some cases it can cause broken MySQL joins. Here is how you can flush the quote for a specific customer in Magento2.

Remove the WHERE clause to flush the quote for all customers.

AWS RDS – You Need (at least one of) The SUPER Privilege(s)

Today I had the opportunity to move a local Magento database to an Amazon RDS. Based on the well-documented article Creating a DB Instance Running the MySQL Database Engine I was optimistic to finish the migration pretty soon. But as you know, there is always something that goes wrong.

After creating the database instance class ( db.m3.large ) I have decided to proceed with some test imports before I change any database credentials in Magento.

Good decision because the first import didn’t run through.

I was able to fix the problem by adding the missing parameter log_bin_trust_function_creators as explained here. Before the next import I had to delete the database and create a new one.

Unfortunately there was another problem with a DEFINER which tried to create a trigger as a different user. On Amazon RDS only a user with SUPER privileges can do that. Therefore, I had to remove the DEFINER from the MySQL schema you see below.

That’s it. Now I was able to import my DB on Amazon RDS without errors.

 

We’re sorry, an error has occurred while generating this email

Today, I was dealing with the following error message on one of our Magento2 production environment.

After spending 2 hours trying to find the source of the problem in our custom modules, I was able to fix the issue by disabling the core module Magento_SampleData.

What is this module for? This module gives you different sample data ( CMS, Catalog, Customers ) which is useful during development and testing phase. For your production environment it is not necessary and also not recommended to have it installed, as you can read here.

Reset Administrator User Password in Magento 2

Magento 2 comes with a CLI that allows you to create a new temporary administrator user within few seconds. Change to the directory where your Magento installation ( such as app or bin folder ) is located and run the following command to create a user support with password 8cd98f00b20.

Voilà!

Now you can go to System > Permissions > All Users and update other users credentials.