Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\vadoo.co.uk\blog\wp-includes\kses.php on line 831

Magento 2.1 Useful Things To Know

Magento 2.1 Useful Things to Know

Sometimes [read always] after a server issue you need to rebuild all the index files and the cache:

When I say Server Issue – I mean just about anything you do with Magento outside of the box including migrations, new themes, almost everything and I’ve lost count the number of times I run these commands [use a .bat file]. So, Command Prompt to your {root} folder e.g. /htdocs/magento and from the command prompt:

C:/....> php bin/magento indexer:reindex
C:/....> php bin/magento cache:clean
C:/....> php bin/magento cache:flush

For those of you who don’t really ‘get’ command prompt stuff: you are running bin/magento/index.php with the argument indexer:reindex¬†via PHP. Ditto for the cache:* options. The php.exe command should be in your path. If in doubt type php -v at the command prompt.

Using phpMyAdmin with Magento

Chances are that you like to look at your Magento Tables from time to time and maybe even move the girl around from server to server [backup example]. She is a healthy girl with 250+ tables and when you export her to a .sql file you’ll see she is of a size that phpMyAdmin obviously exports, but will moan if you try and re-import.

In fact your PHP xampp [or your flavour] probably isn’t too keen on files or tables of this size, so my advice is to seriously bump the defaults for these. Most of the common ones you’ll find in php.ini such as upload_file_size etc..For development I generally set these to no-limit [0 or -1].

One that you might not know about as a phpMyAdmin user is config.default.php in your phpMyAdmin/libraries folder. You are not supposed to edit this file and instead create config.inc.php in your phpMyAdmin root. Maybe good advice and do this if you want, but I prefer to just edit the default file. Your call.

The chap you need to edit is the default timeout of 300 ms or as they call him

$cfg['ExecTimeLimit'] = 300;

Set to zero rather than 300 and you can happily watch paint dry with phpMyAdmin. Try a Magento db import and you’ll see it runs 1200+ queries. This will often take more than 300ms and without this setting it will fall over.

Moving [or copying] your Magento Shop

As discussed above copying the database from one server to another is not without its troubles, but the second step is likely to be a simple upload or copy across of your \htdocs\Magento\{my-shop} folder from server #1 to server #2.

Simple enough, but when you come to then run the shop on server #2 you’ll get an autoload error asking you to run the composer install.

On server#2 drop to the root folder of your new Magento shop and you’ll see a file called composer.json. You can leave that alone, but you’ll need to create a new file called auth.json which holds the public and private keys for your shop. This is where you’ll need access to your Magento on-line account¬†https://marketplace.magento.com/ and you’ll need your public and private keys for Mag 2. These need to go into a file called auth.json looking like this:

 "http-basic": {
         "repo.magento.com": {
                 "username": "{public-key}",
                 "password": "{private-key}"

Then you are good to go and you can run composer install; if you don’t have the above auth.json file then you’ll be prompted for a username and password. This is NOT your marketplace login | password, but the above public and private keys used as a username/login | password combo.


As you’ve moved the whole shooting match from server#1 to server#2 you’ll just need to update the baseURLs in the new mySQL database. I’ll assume that server#1 was installed with dev.magento.net and your server#2 is going to be live.magento.net [or staging.magento.net]. So on server#2 open up your myPhpAdmin and the newly copied across Magento database.

You’re looking for the table called core_config_data and it will look something like this:

As you would do with any table, just update the above to your new URLs for the new server live.magento.net and then you’ll be good to go and after the last bit below you can open up your Magento shop with the new URL live.magento.net, which will be running on server#2 with its database.

The last bit of house-keeping is to re-build everything on server#2, so follow the process of re-indexing and cleaning cache files at the top of this post [on your new server#2 – obviously].

So, in summary a totally replicated shop.







Leave a reply:

Your email address will not be published.

Site Footer