Shopware

Shopware 5.7.18 PDF Invoice Fix: A Step-by-Step Guide

Shopware PDF settings configuration
Shopware PDF settings configuration

Shopware 5.7.18 PDF Invoice Fix: A Step-by-Step Guide

Updating your Shopware store is crucial for security and accessing the latest features. However, sometimes updates can introduce unexpected issues. One common problem encountered after upgrading to Shopware 5.7.18 is the failure to generate PDF invoices. This issue often manifests as a fatal error related to Smarty template security settings.

This guide provides a clear, step-by-step solution to resolve this PDF invoice generation problem, ensuring your business operations run smoothly. We'll walk you through the cause of the error and provide a practical workaround to get your invoices working again.

Shopware PDF Invoice Error Fix

Understanding the Problem

After updating to Shopware 5.7.18, you might encounter the following error message when trying to generate a PDF invoice:

Fatal error: Uncaught SmartyException: directory '/home/chrvwgsg/www.bf-sportwagen.de/themes/Frontend/BFSportwagen/documents/index.tpl' not allowed by security setting in /home/chrvwgsg/www.bf-sportwagen.de/engine/Library/Smarty/sysplugins/smarty_security.php:379

This error indicates that Shopware's Smarty template engine is blocking access to the index.tpl file, which is essential for generating PDF documents. The system flags the template directory as insecure, preventing invoice creation.

Why Does This Happen?

The root cause of this issue lies in Shopware's security settings for Smarty templates. After the update, the system might incorrectly identify the directory containing your PDF template files as untrusted. This can be due to various factors, including:

  • Changes in Shopware's security policies.
  • Manual modifications to core files (though this is generally discouraged).
  • Incompatibilities with certain themes or plugins.

While identifying the exact cause can be complex, the following workaround provides a quick and effective solution.

The Solution: A Practical Workaround

This solution involves moving your PDF template files to the root directory and updating the Shopware settings to reflect the new location.

Step 1: Access Your Shopware Files

You'll need access to your Shopware installation files, typically via FTP or a file manager provided by your hosting provider. Locate the documents folder within your active theme's directory. The path will look something like this:

/themes/Frontend/[YourThemeName]/documents/

Replace [YourThemeName] with the actual name of your active theme.

Step 2: Copy the Template Files

Copy all the files from the documents folder (including index.tpl and any other template files) to the root directory of your Shopware installation. This is the same directory where you find files like shopware.php and index.php.

Step 3: Update PDF Creation Settings

Log in to your Shopware backend and navigate to Grundeinstellungen → PDF Erstellung (Basic settings -> PDF creation). Here, you'll need to adjust the paths to your PDF template files.

Specifically, modify the path for the invoice template to point directly to the index.tpl file in the root directory. Instead of a path like themes/Frontend/[YourThemeName]/documents/index.tpl, it should simply be index.tpl.

Shopware PDF Settings

Step 4: Clear the Cache

After making these changes, it's essential to clear the Shopware cache. You can do this in the backend under Einstellungen → Cache/Performance → Cache leeren (Settings -> Cache/Performance -> Clear cache). Select all cache options and click "Clear cache".

Step 5: Test Invoice Generation

Now, try generating a PDF invoice again. The error should be resolved, and your invoices should be created successfully.

Important Considerations

  • Theme Updates: If you update your theme in the future, you might need to repeat these steps, as the theme update could overwrite the changes.
  • Custom Templates: If you've heavily customized your PDF templates, ensure the copied files include all your modifications.
  • Core File Modifications: Avoid modifying core Shopware files (like smarty_security.php) unless absolutely necessary and you fully understand the implications. The workaround described here is generally preferable.

Conclusion

While a Smarty security error preventing PDF invoice generation after a Shopware update can be frustrating, this workaround provides a simple and effective solution. By moving your template files and updating the Shopware settings, you can quickly restore invoice functionality and keep your business running smoothly. Remember to clear the cache after making changes and to keep these steps in mind when updating your theme in the future.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools