Since mostly all the tutorials I read about this seemed to be wrong I figured it would be a good idea to write this down for future use.

First thing’s first, disable auto-redirects. Set the following setting to NO:

Now make sure Magento expects you to be hitting Admin on a different URL, otherwise it will STILL redirect you back.
Fill in whatever domain/subdomain you want to use here:

Setting both these things will stop Magento from redirecting you back to the (loadbalanced cluster of) front-end webserver(s).

So I just ditched my previous VPS at TransIP and setup my new one at DigitalOcean since they are cheaper, faster and still have a location in Amsterdam. For the same price as TransIP I also get a backup service and a really, really nice interface to handle my server. The disk bandwidth is insane, all the way up to 340MB/s compared to my old 70MB/s max.

So far I’m very happy! Note to self on setting up nginx though, check the fastcgi_params file to make sure it looks like the block below, otherwise it won’t work:

Specifically the SCRIPT_FILENAME, otherwise you will just get white pages.

Thank you Marius for this one! Something went wrong during an import and this saved a lengthy slow fix function which would take at least a whole day to run.

So this little trick is so silly I’m ashamed I didn’t come up with it myself.. During an import I was experiencing product saves taking up to 1 second at a time. After some searching I realized it was reindexing each product on save so the easiest way to get around this is by putting indexing on “Manual” instead of on “Update on save”.

This improved save speeds by up to 10x! Ok, reindexing afterwards can take quite a while, but at least you have some control over it and can decide when to run it.

Manual Indexing Magento

I get this error regularly setting up new nginx+php-fpm servers and I keep forgetting the fix.
So here’s another note-to-self..

  1. Check session save path
  2. Check permissions of the directory

    This should tell you which user owns the session dir, most likely this is NOT the same as your php-fpm user.
  3. Check user of php-fpm

    I have set php-fpm set as nginx user, so I gotta fix the owner of the session dir.
  4. Fix owner and/or permissions
  5. Restart php-fpm
  6. Test phpmyadmin again, it should work now

UPDATE 2015-11-09: I forgot one function

Just a few little functions as an example of how I checked for various attribute values in our Magento store. If the value exists the value id is returned and if it doesn’t the value is first inserted and the resulting id is then returned. In this example I will be using the attribute Manufacturer since it will be something people regularly use. Of course the code can be changed to be made to work with any attribute like flavor, color, size etc:

Mind you I found this code on the Magento forums but it was difficult to find, so I copied it here for safe keeping.

Magento reads max_input_vars from the .htacess or from what was set in index.php or php.ini
If that value was not set (our installation of) php defaults to 1000. If you then try to change a category in Magento with more than 1000 products it will spit out this error:

And it will proceed to limit your category to 1000 products!

An easy fix is to add this to your php.ini

This should give you the option to have 10.000 products in one category (should be plenty usually, right?)

No matter what I was doing during my import I was getting errors on setCategoryIds. It didn’t matter if I gave it an array of ids or a string, it would always error out with the exception “Invalid category IDs.”.

I had a look at the actual function and decided to change how I set my category ids:

So now, I just use the last bit 😛
I create an array of Category Ids and set it with setData() and now all the categories are set :/

Seriously, Magento really pisses me off sometimes..