Uncommon OpenCart issues

My whole life I’ve been spending a considerable percentage of my web development projects time dealing with errors rather than enjoying the coding part, rare are the projects I had to accomplish without being forced to come across an unexpected error or bug, sometimes easy to fix and sometimes a hopeless cause especially when you’re working with a framework like OpenCart.

It’s not uncommon to me to face a familiar issue I managed to correct in the past but find myself unable to remember how I fixed it in order to deal with it now and this has made me mad more than once so this page is, before all, a way for me to keep note of the issues I face the most on OpenCart and how I fixed them, in the second plan, I hope it will save the time of some of you so you can spend it on a more productive work.

This page will get updated each time a new OpenCart issue occures to me.

OpenCart Installation & Update Issues:

1.Install infinite loop

if you searched this on Google then you’ve come to the right place:

install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/index.php

this is how your url looks like if your OpenCart store is stuck in infinite loop during install:

These issues happens mostly when you open your OpenCart store url for the first time like when you try to install OpenCart or upgrade to a newer version, the store enters in infinite redirect loop and ends up by displaying a “ERR_TOO_MANY_REDIRECTS” error page, but in some rare cases this can suddenly happen to your store even if it has been running before, in this case you should preferably try to restore your website to a previous backup or find out what has changed since the last working version because this issue is supposed to happen only when one is trying to install or upgrade opencart which means that you may have lost some important files on your OpenCart directory, or what’s left from your store is maybe pointing to the wrong location.
if you get this issue upon install or update then this is how to deal with it:

Browser re-directions cache:

Make sure your browser’s cache isn’t interfering, so clear it up, or try on a different browser, different computer just start by testing your page as far as possible from your usual browser, if you obtain a different result then focus on clearing your browser’s cache before you proceed further, browser’s cache can still interfere when you try the following steps too so keep in mind that you need to clear your cache each time you try a new solution, you don’t want to pass by the solution because of this ridiculous exception.

Try adding “upload” to the url

if you’re trying to install OpenCart using this url: yoursite.com then try accessing it from here instead: yoursite.com/upload, if this works then you’ve done something wrong when you extracted the installation compressed file so stop just there because that installation isn’t what we’re looking for, you probably placed the folder upload inside your store’s root directory so what you have to do is simple: move all the upload folder’s content to the parent directory, in other words move all the upload folder’s files to your store’s root directory

disable the .htaccess file temporarily

This file may contain some redirection rules that causes a conflict that prevents the installation process from starting correctly, look for the file and disable it by renaming it temporarily, some ftp clients hides it so need to perform an extra step in order to find it, it should be in the directory of your store.

2.Uncaught TypeError: Argument 2 passed to Event::trigger() must be of the type array, string given..

this is the full error message:

Fatal error: Uncaught TypeError: Argument 2 passed to Event::trigger() must be of the type array, string given, called in xxx/system/storage/modification/system/engine/loader.php on line 140 and defined in xxx/system/engine/event.php:59 Stack trace: #0 xxx/system/storage/modification/system/engine/loader.php(140): Event->trigger('language/en-gb/...', 'en-gb') #1 xxx/system/framework.php(136): Loader->language('en-gb') #2 xxx/system/startup.php(104): require_once('xxx/...') #3 xxx/install/index.php(37): start('install') #4 {main} thrown in xxx/system/engine/event.php on line 59

I got this issue when I tried to upgrade from OpenCart 2 to 3, in my case it was related to extensions so I had to disable those before proceeding to update but now I started the installation process It was too late because I had no more access to the admin panel, if you’re in the same position than try this:

Disable OCMod extensions using FTP:

you can also use the file manager of your host account to perform this, simply rename the folder system/storage/modification to a different name like system/storage/modification_temp, this will temporarily disable all your old OCMod extensions, but don’t forget to create a new empty folder with the same name modification because OpenCart will need that in order to proceed with the installation. Once the installation is done you can enable your extensions again but preferably one by one that way you’ll make sure if one of your extensions is responsible of a potential error.

Disable OCMod extensions from database:

if the previous solution didn’t work then you may perform this as an extra step, you need to access your database from your host panel, Iook for phpmyadmin or a similar tool, then access the oc_modification table on your OpenCart’s database, there you should find all your extension, you can disable them by changing each row’s status col value to 0
Or you can simply execute this mySql query which will do the work for you automatically:

update `oc_modification` set status=0

Make sure to replace oc_modification by the correct name of your current table, the table may have a different prefix like mysite_ instead of oc_, in this case the query should be:

update `mysite_modification` set status=0

3.Warning: fopen(/storage/cache/cache.catalog.language.): failed to open stream: No such file or directory in xxx/system/library/cache/file.php on line 49

I faced this issue after installing OpenCart 3 and trying to move the “storage” folder outside its initial directory as per Opencart’s suggestion. After you install OpenCart 3 and you access your admin panel, a popup (Importan Security Notification) will appear with the following message: ” It is very imporant that you move the storage directory outside of the web directory (e.g. public_html, www or htdocs).”

Now the problem may occur either if you clicked on “move” but the process didn’t go well, or if you tried to move the directory manually in an incorrect way, in both cases here’s what you need to make sure of:

Make sure the folder “storage” is in the right location

in the very beginning, the directory storage is supposed to be in the system directory right within your root directory but its location should change according to the OpenCart system notification, therefore it should move to the root directory. In other words move the system/storage folder to the parent folder, your root directory should now look like:

Make sure the config.php files are pointing to the right location

Opencart has two config.php files, one is location within the root directory and the other inside the admin directory, so both files has paths that points to the storage directory and you need to make sure that the paths are corrects, in order to do this, edit both files and change this line:

define('DIR_STORAGE',....

to this;

define('DIR_STORAGE', '/storage/');

but this might not work sometimes, because the paths are relative so the root folder may sometime be longer than a simple slash ( / ), the trick here is to find the absolute path to your root directory, it can be something like /usr/www/users/xxxx/ or /home/xxxx/public_html … depending on your host provider so in order to be sure just copy the path from the config.php file itself, see the picture below:

4.Warning: fopen(xxxxx/storage/logs/openbay.log): failed to open stream: No such file or directory in xxxxx/system/library/log.php on line 22

this issue may happen if you have got the popup Importan Security Notification on your admin panel (see issue 3) and you clicked on the red move button but it didn’t go well, if this is the case then using your ftp client or your host file manager go and take a look at the storage folder within your root directory and make sure its content looks like this:

if you have a different content, like missing folders than it means that the storage directory hasn’t been moved correctly by OpenCart that’s why you need to do it manually so just delete the incomplete storage folder from your root directory then move the original one that you should find within the folder system then place it where the previous storage folder (the one you deleted previously) was located (the root directory), read the issue 3 for more information about this process.

5.Warning: fopen(xxxx/catalog/view/theme//stylesheet/bootstrap.css): failed to open stream: No such file or directory in xxxxx/catalog/controller/startup/sass.php on line 14

this rare issue happens when OpenCart tries to load your theme name from the database without results, that’s why the link is inccorect : xxxx/catalog/view/theme//stylesheet/bootstrap.css
so in order for the file to load correctly, the path should look like:
xxxx/catalog/view/theme/default/stylesheet/bootstrap.css for example
so this is how to force OpenCart to display the correct theme name:

Save your theme from the admin panel

open the admin panel and go to extensions>extensions then chose theme in the drop-down , a list of your installed themes should appear:

click on the blue edit button located in the same row as your active theme (the one with “enabled”) then without even making any specific modification just save and go test if that has resolved the issue.

make sure your oc_settings table is correct

this solution is tricky because I don’t have a code you can just copy past somewhere into your code or phpmyadmin, you need to open your phpmyadmin and compare your oc_settings table to a correct one, I fixed mine by importing a freshly created OpenCart 3 oc_settings table into my store’s database, by replacing my incorrect table with the correct one, the issue was gone but be careful because this means you’ll have to lose your old settings, I didn’t mind setting everything like it was manually as this would take less time than looking for a solution that would save my previous settings.

Opencart Admin Panel Issues

1. Warning: You do not have permission to access the API!

Have you tried to edit or delete an order on your opencart system without any success? if you’re getting a message like:

chances are you don’t have permissions to access opencart’s api but don’t panic this should be a simple fix.

Make sure your ip address is authorized in the API section

login to your panel and go to System>Users>API

click on edit and go to IP Addresses and add your ip address there then save.
this should be the most common reason why you can’t delete or edit your orders but if it doesn’t work try the next suggestion.

Make sure your user group has all the permissions

The administrator group is supposed to have all the permissions by default but give it a look in case it has changed somehow.
go to System>User>User Groups

make sure all Access Permissions and Modify Permissions are checked, check them if not then save.

Disable API IP checks once and for all

if you have a dynamic IP the previous solutions might not suit you as you have to reproduce them each time your ip changes, so instead of adding your ip manually each time you can just apply this solution which will relief you once and for all from this annoying task;
simply install this extension and it will do the work for you automatically, don’t forget to clear your store’s cache after install.

Also read...

Comments

  1. Buongiorno
    GRAZIE
    Con il vostro aiuto sono riuscito a risolvere il problema della fastidiosa finestra:

    Make sure the folder “storage” is in the right location.

    GRAZIE SALUTI

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *