This guide contains a step-by-step guide on how to accelerate your Shopware store with BunnyCDN. There is a community created Shopware adapter for BunnyCDN which we will be installing.
1. Create your BunnyCDN Storage Zone
The BunnyCDN Shopware adapter works by uploading your content to one of our Storage Zones, and then linking to it via a Pull Zone that is set up to use a Storage Zone as its origin. Before you begin to configure your Shopware site, you need to make sure you have your Storage Zone set up and attach it to a Pull Zone.
2. Install the BunnyCDN Shopware adapter
The first thing you need to do is download the Shopware adapter from Github. The releases page here will have the latest download for the adapter available. You need to download the file called "TinectMediaBunnycdn.zip", and we will need this for the next step.
The next thing we need to do is install the BunnyCDN Shopware adapter onto our site. To do this, navigate to the Plugin manager, by clicking on "Configuration" (on the top blue bar) (1), and then selecting "Plugin Manager" (2)
Once the plugin manager has loaded, click on "Installed" (1), and then "Upload Plugin" (2), and then navigate to the ZIP file we downloaded earlier (3):
Once you've uploaded the plugin, you will see it appear in the list of plugins, under "Uninstalled". Click the Green + sign to enable the plugin.
After you've enabled the plugin, it then goes into an "Inactive" state, and we need to activate it. In order to do that, click on Pen next to the plugin name in the list (1) and then click on "Activate" (2).
If you get a prompt about clearing caches, press Yes.
3. Configure Shopware to use BunnyCDN
We've now installed the Plugin on Shopware, we need to configure it so that it knows how to send data onto BunnyCDN to cache it. You'll need access to your webserver, via SSH or FTP for this, because we need to edit a PHP file.
In your Shopware install directory, look for a file called "config.php", which should contain an array full of information about your Shopware database. We need to add some configuration lines to that to tell Shopware to use your CDN.
The configuration that we need to append to the file is as below:
'cdn' => [ 'backend' => 'bunnycdn', 'adapters' => [ 'bunnycdn' => array ( 'type' => 'bunnycdn', 'mediaUrl' => 'https://PULLZONE.b-cdn.net/', 'apiUrl' => 'https://storage.bunnycdn.com/STORAGEZONENAME/', 'apiKey' => 'secret-api-key' ) ]
You need to enter your Pull Zone name into the "mediaUrl" line, and enter your Storage Zone name into the "apiUrl" line, and then enter the API key (that you can view on your FTP & API Access page) as the password.
The final thing we need to do, is tell Shopware to upload all of your content that is currently hosted locally, onto the Storage Zone. You can do this with a single command, which is:
"bin/console sw:media:migrate --from=local --to=bunnycdn"
Congratulations, you've now accelerated your Shopware site with BunnyCDN! You can now reap the benefits of our super fast network of global caches, as well as saving money on your origin bandwidth costs.