# OCMOD not working in OpenCart 3.0: how to find out why a modification didn't apply

> Step-by-step OCMOD diagnostics in OpenCart 3.0: from the status and the "Refresh" button to ocmod.log, copies in storage/modification, themes, the theme editor and cache.

Джерело: https://opencartcode.com/en/wiki/dev-events-ocmod/ocmod-not-working
OpenCart: 3.0
Оновлено: 2026-11-28

If OCMOD isn't working in [OpenCart](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#opencart) 3.0, the cause is almost always in one of three places: the modification wasn't refreshed with the "Refresh" button, the search string wasn't found in the file, or a modified copy exists but the store is serving a different file or a cached version. Below is a check sequence that lets you find in a few minutes which step the chain breaks at.

This article covers OpenCart 3.0. How OCMOD changed in 4.1 is described in the article [OCMOD in OpenCart 4.1](https://opencartcode.com/en/wiki/dev-events-ocmod/ocmod-opencart-4), and the syntax rules are in the article [OCMOD syntax in OpenCart 3.0](https://opencartcode.com/en/wiki/dev-events-ocmod/ocmod-syntax).

## Is the modification installed and enabled at all?

Start with the simplest check, because this is where the most time gets lost. Open "[Extensions](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#extensions) → Modifications" and find the modification by its name.

- **It isn't in the list.** The installation through "Extensions → Installer" didn't get to the step with `install.xml`. The most common cause is that the XML has no `<code>` element: the installer then shows the error "Unique code is required for modification XML!". Another cause is that `install.xml` is not at the root of the archive but in a nested folder.
- **It's there but disabled.** Enable it and be sure to click "Refresh".
- **The modification is duplicated under a different name.** Reinstalling with the same `code` replaces the old entry, but with a different code you get two modifications competing for the same lines. Delete the extra one.

Extensions → Modifications: status, the "Refresh" button and the log tab · OpenCart 3.0.5.1

A separate case is the files in `system/*.ocmod.xml`. Developers put them there for quick tests: they are applied on "Refresh", but they don't appear in the modifications list. If the site has a change that isn't in the list, check `system/`. And the reverse: verify that the file name really ends with `.ocmod.xml`, otherwise the core won't read it.

## Did you click "Refresh" and did it complete?

In 3.0 a modification doesn't take effect on its own. Copies of the changed files are created only at the moment of "Refresh", and enabling, disabling or deleting a modification changes nothing until the refresh is done. This also applies in reverse: a disabled modification keeps working until the next "Refresh".

The "Clear" button deletes all copies, including those created by the service `system/modification.xml`, through which the core picks up the changed files at all. After "Clear" without "Refresh", no modification works.

Make sure the refresh completed successfully, that is, that a success message appeared. If instead there is a blank page or an error:

1. Open "System → Maintenance → Error Logs" and look at the latest entries.
2. **OpenCart 3.0.4.1:** the refresh stops with a fatal error if any XML lacks the root `<modification>` or an operation lacks `<search>` or `<add>`. **OpenCart 3.0.5.1:** such places are skipped.
3. Check that the store wasn't left in maintenance mode: during the refresh the core turns on `config_maintenance` and restores the previous value only at the end. An interrupted refresh leaves it on, and customers see the maintenance page.

> The fastest way to find a problematic modification is a bisection: disable half of the modifications, click "Refresh", look at the result, and repeat. Do this on a test copy of the store, not on the live site.

## What does ocmod.log say?

The modification log is the main diagnostic tool. It is available on the log tab of the modifications page and is stored in the file `ocmod.log` in the logs directory. The log is *appended* on every refresh, so first clear it with the button on the same tab, then click "Refresh" and read the fresh entry.

Example

```bash
MOD: My badge

FILE: catalog/controller/product/product.php
CODE: $data['model'] = $product_info['model'];
LINE: 257

FILE: catalog/view/theme/default/template/product/product.twig
CODE: <div id="product">
NOT FOUND - OPERATIONS ABORTED!
----------------------------------------------------------------
```

How to read the lines:

| Line | What it means |
| --- | --- |
| `MOD:` | the start of a modification; after the colon is the content of `<name>` |
| `FILE:` | the file to which the operations are applied; if the file is not in the log, the path in `path` found nothing |
| `FILE: (sub modification)` | the file was already changed by a previous modification; the search runs on its result |
| `CODE:` / `REGEX:` | what was searched for |
| `LINE:` | the line number where the match was found; the change is applied |
| `NOT FOUND - OPERATION SKIPPED!` | not found; the operation with `error="skip"` was skipped |
| `NOT FOUND - OPERATIONS ABORTED!` | not found; the remaining operations of this block `file` were not performed |
| `NOT FOUND - ABORTING!` | not found with `error="abort"`; all changes of the modification were rolled back |

If `FILE:` for the needed file doesn't appear at all, check `path`: it must start with `catalog/`, `admin/` or `system/` and match the real path, case-sensitive. The path to a [storefront](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#storefront) [template](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#template) includes the theme directory: `catalog/view/theme/default/template/…`.

## Why isn't the search string found?

When the log shows `NOT FOUND`, open the file that was searched and compare by hand. Typical causes:

- **A multi-line `search`.** A regular search in 3.0 compares the text against each line separately, so a search spanning two lines will never be found. Leave one distinctive line or switch to `regex="true"`.
- **The line was changed by another modification.** If there is `FILE: (sub modification)` nearby, the file has already been changed. Compare `search` not with the original but with the copy in `storage/modification/` after disabling your modification.
- **A different core version.** Some files changed between 3.0.4.1 and 3.0.5.1. Check a modification written for one version against the files of the version installed on the store.
- **Invisible characters.** Non-breaking spaces or "smart" quotes copied from a browser don't match the code. Retype the line manually.
- **CDATA and [special](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#special) characters.** Without `<![CDATA[…]]>`, the characters `&`, `<`, `>` break the XML.
- **A wrong regex.** An error in the expression is dangerous: `preg_replace()` returns `null`, and the file contents in memory become empty. Test the expression separately, for example with `php -r`.

Remember that the search is case-insensitive and matches part of a line: an overly short `search` such as `}` will match dozens of places, and without `index` the change is applied to all of them.

To avoid repeating the cycle "clear the log → Refresh → read `ocmod.log`" after every edit, you can use the free module [OCT OCMOD Editor: OCMOD modification editor and checker](https://opencartcode.com/en/marketplace/product/oct-ocmod-editor) for OpenCart 3.0. It applies modifications in memory using the same rules as the core and, before "Refresh", shows for each operation whether the line was found, on which line the match is, and what will happen next. This also reveals errors that the refresh skips silently, such as an extra space in a path or a regex that empties the file.

## The copy exists, but nothing changed on the site?

Sometimes the log shows `LINE:`, the copy is in `storage/modification/`, and the store still behaves as before. Check in order:

1. **Is it the right file.** Open the copy, for example `storage/modification/catalog/controller/product/product.php`, and find your insertion. If it isn't there, go back to the log.
2. **Is the theme the same.** The `event/theme` handler takes the template from the active theme's directory if the file exists there, and only otherwise from `default`. Modifying the `default` template won't affect a theme with its own copy. Use `catalog/view/theme/*/template/…` in `path`.
3. **Is the theme editor overriding it.** If the template was saved in "Design → Theme Editor", the core substitutes the code from the database, and the copy in `storage/modification/` is not read. Delete the saved version in the editor or move your change there.
4. **Template cache.** The admin control panel has a Developer Settings button with a theme cache clear. Clear it after changes.
5. **OPcache.** If OPcache on the server runs with file timestamp validation disabled, PHP executes the old compiled code. Restart PHP-FPM or reset OPcache through the hosting tools.
6. **The storage directory.** If `storage` was moved manually outside the site root, check that `DIR_STORAGE` is the same in `config.php` and `admin/config.php`. Otherwise the admin writes copies to one directory and the storefront reads from another. The PHP user must also have write permission to `storage/modification/`.
7. **Browser and CDN cache.** For CSS and JS changed by a modification, clear the browser cache and the CDN.

For the locations of directories and configs, see the articles [the storage directory in OpenCart](https://opencartcode.com/en/wiki/dev-architecture/opencart-storage) and [config.php in OpenCart](https://opencartcode.com/en/wiki/dev-architecture/opencart-config-php).

## What to do if the modification can't be fixed at all?

Sometimes it's simpler to remove the modification than to adapt it to a specific theme and set of modules. Options:

- **Rewrite it as an event.** If the change only adds a variable to a template, alters a model's result or modifies the finished HTML, an event doesn't depend on the text of lines and doesn't conflict with other modifications. See [changing a template via view/*/before](https://opencartcode.com/en/wiki/dev-events-ocmod/event-view-opencart) and [intercepting models](https://opencartcode.com/en/wiki/dev-events-ocmod/opencart-event-model-after), and for the selection criteria, the article [events or OCMOD](https://opencartcode.com/en/wiki/dev-events-ocmod/events-ci-ocmod).
- **Split the operations.** Move independent changes in one file into separate `<file>` blocks or give them `error="skip"`, so one unfound operation doesn't cancel the rest.
- **Add `ignoreif`.** If another module has already inserted the same code, the operation will be skipped instead of inserting it twice.

After every change to the XML, the modification must be reinstalled (or edited in the database), "Refresh" clicked, and the log read again. For more on OCMOD, see the blog: [OCMOD in OpenCart: code changes without modifying system files](https://opencartcode.com/en/blog/ocmod-v-opencart-pravki-kodu-bez-zmini-sistemnix-failiv).

## Summary

- Check that the modification is in the list, enabled, and that after any change "Refresh" was clicked with a success message.
- Clear `ocmod.log`, refresh, and read the fresh entry: `LINE:` means applied, `NOT FOUND` means the line was not found.
- The search works line by line and depends on changes made by previous modifications and on the core version.
- If the copy exists but the site hasn't changed, the culprits are the theme, the theme editor, the template cache, OPcache, or a mismatch in `DIR_STORAGE`.
- Fragile modifications are often easier to rewrite as events.

Other materials on modifications and events are in the section [Events and OCMOD](https://opencartcode.com/en/wiki/dev-events-ocmod).

## FAQ

**Can you see which modifications changed a specific file?**

Yes, in a fresh ocmod.log look for FILE lines with the needed path: above each block is a MOD line with the modification name. The sub modification mark shows that another modification had already changed this file before.

**Why did a modification start working differently after updating the module?**

Installing an XML with the same code replaces the old modification, but the copies are rebuilt only after "Refresh". Click "Refresh" and check the log: the new version may be looking for different lines.

**Is it safe to delete the contents of storage/modification manually?**

Yes, it's the same as the "Clear" button: the copies are then recreated by the "Refresh" button. But until you click it, no modification will take effect on the site.
