# product table in OpenCart: products, descriptions, categories and related tables

> How a product is stored in OpenCart 3.0 and 4.1: the product table and its companions (descriptions, categories, stores, options, prices, images, codes and variants), with version differences.

Джерело: https://opencartcode.com/en/wiki/dev-database/tablicia-product-opencart
OpenCart: 3.0, 4.1
Оновлено: 2026-11-25

The `product` table in OpenCart stores only the "technical" part of a product: model, price, quantity, weight, and status. The name and description are in `product_description`, categories are in `product_to_category`, and store visibility is in `product_to_store`. A dozen or so other tables hold images, options, customer-group prices, and relations. Below is where things live in 3.0 and 4.1, what conditions the [storefront](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#storefront) applies, and why it is better to write products through the model.

Examples are for OpenCart 4.1; in 4.0.x, model triggers and event handling differ. For the overall database map, see the article [OpenCart database tables](https://opencartcode.com/en/wiki/dev-database/opencart-database-tables).

## What is stored in the product table itself?

The primary key is `product_id`. The main columns are the same in both branches:

| Columns | Purpose |
| --- | --- |
| `model`, `location` | model SKU and storage location |
| `price`, `tax_class_id`, `points` | base price excluding tax, tax class, bonus points for purchase |
| `quantity`, `subtract`, `minimum`, `stock_status_id` | stock quantity, whether to subtract it on order, minimum quantity, stock status for out-of-stock items |
| `weight`, `weight_class_id`, `length`, `width`, `height`, `length_class_id`, `shipping` | weight, dimensions and units, whether shipping is required |
| `image`, `manufacturer_id` | main image and manufacturer |
| `status`, `date_available`, `sort_order` | enabled or not, date from which the product is available, sort order |
| `date_added`, `date_modified` | service dates |

The differences between versions in this table are significant:

- **OpenCart 3.0:** has the code columns `sku`, `upc`, `ean`, `jan`, `isbn`, `mpn`, and the view counter `viewed`.
- **OpenCart 4.1:** these columns are gone. Codes have been moved to the `product_code` table, and views to `product_viewed` and `product_report`. Instead, `master_id`, `variant`, and `override` have appeared for product variants, along with `rating`.

A import or feed module written for 3.0 that reads `p.sku` will get an SQL error about an unknown column in 4.1. Keep this in mind when porting any code that works with products directly.

## How are descriptions, categories, and stores structured?

### product_description

(product_id, language_id), with one row per language. Fields: `name`, `description`, `tag`, `meta_title`, `meta_description`, `meta_keyword`. There is an index on `name`. A product without a row for the current language will either not appear on the storefront or will appear without a name, so the import must create a description for every enabled language.

### product_to_category

A many-to-many relation with the primary key `(product_id, category_id)` and a separate index on `category_id`. A product can belong to several categories. The core has no concept of a primary category: if one is needed for [breadcrumbs](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#breadcrumbs) or feeds, that logic belongs to the module.

### product_to_store and product_to_layout

`product_to_store` determines which stores the product is visible in; the default store has `store_id = 0`. `product_to_layout` with the key `(product_id, store_id)` sets the page layout for the product on a specific store. Without a row in `product_to_store`, the product will not be found on the storefront even with status 1.

Example

```sql
-- товари категорії 20, видимі в головному магазині, з назвою мовою 1
SELECT p.product_id, p.model, p.price, pd.name
FROM oc_product_to_category p2c
JOIN oc_product p ON (p.product_id = p2c.product_id)
JOIN oc_product_description pd ON (pd.product_id = p.product_id AND pd.language_id = 1)
JOIN oc_product_to_store p2s ON (p2s.product_id = p.product_id AND p2s.store_id = 0)
WHERE p2c.category_id = 20
  AND p.status = 1
  AND p.date_available <= NOW();
```

These exact conditions (status, `date_available`, store, language) are applied by the storefront in both branches. If a product exists in the admin but is not visible on the site, check them one by one. The `oc_` prefix and language ids here are examples: in code, use `DB_PREFIX` and `config_language_id`.

## Where are prices, discounts, and specials stored?

The base price is `product.price`. Prices for customer groups and quantities are stored separately, and the branches diverge here:

| What | OpenCart 3.0 | OpenCart 4.1 |
| --- | --- | --- |
| Quantity discount | `product_discount`: group, quantity, priority, price, dates | `product_discount` with the same fields plus `type` and `special = 0` |
| Special price | separate `product_special` table | `product_discount` row with `special = 1` |
| Value type | always a fixed price | `F` is a fixed price, `S` subtracts an amount, `P` is a percentage of the price |
| Bonus points for purchase | `product_reward` per customer group | `product_reward` |

The storefront selects the row for the current [customer group](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#customer-group), quantity 1, and valid dates, with the lowest priority, and with equal priority, the lowest price. Empty dates are stored as `0000-00-00` and mean "no limit".

> In 4.1, the value of `price` in the `product_discount` row is not always a price: for the `P` type it is a percentage, and for `S` it is an amount to subtract. A report or feed that simply takes `price` from this table, as in 3.0, will show incorrect prices.

The cart price is calculated by the cart library with separate queries to these same tables, so changing the price only at the catalog model level is not enough. For model interception and its limits, see the article [event model in OpenCart](https://opencartcode.com/en/wiki/dev-events-ocmod/opencart-event-model-after).

## How are options, attributes, filters, and images stored?

### Options

The options directory (`option`, `option_value`, and their descriptions) is shared across all products. Linking to a product happens in two tables:

- `product_option`: which option the product has and whether it is required (`required`). For text options and dates, the default value is stored in `value`.
- `product_option_value`: values for select, radio, or checkbox options, with their own `quantity` and `subtract`, as well as price, points, and weight adjustments: `price`/`price_prefix`, `points`/`points_prefix`, `weight`/`weight_prefix`. The prefix in the product form is `+` or `-`.

Option stock is independent of product stock: if `subtract` is enabled for an [option value](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#option-value), both are subtracted on order.

### Attributes and filters

`product_attribute` has the key `(product_id, attribute_id, language_id)` and the value text separately for each language. `product_filter` is simply `(product_id, filter_id)` pairs; filter values are described in the `filter` directory. Therefore, characteristics for comparison are better kept in attributes, and values for filtering in filters. For the store-side view of filters, see the article [product filter in OpenCart](https://opencartcode.com/en/wiki/catalog/opencart-filter).

### Images, related products, files

The main image is `product.image`, additional ones are `product_image` with `sort_order`. Paths are relative to the `image/` directory. `product_related` contains `(product_id, related_id)` pairs; the admin keeps the relation in both directions, and when a product is deleted, the core cleans up both directions. `product_to_download` links files for download after payment.

## What's new with products in OpenCart 4.1?

### Product codes: product_code and identifier

The `identifier` table is a directory of code types (SKU, UPC, EAN, JAN, etc., with the `validation` field), and `product_code` holds values for a product: `product_id`, `code`, `value`. Selecting a product by SKU in 4.1 is a JOIN with `product_code` on `code = 'SKU'`, not a condition on the `product.sku` column.

### Product variants

A variant is a separate `product` row with `master_id` pointing to the master product. `variant` stores JSON of the selected option values, and `override` stores JSON of the fields the variant does not inherit from the master. Fields not marked in `override` are inherited by the variant from the master product. Therefore, editing such a field directly in a variant may be overwritten by the admin the next time the master product is saved. Change shared fields in the master product, and in the variant only those marked in `override`.

### Views and subscriptions

The view counter has moved from `product.viewed` to `product_viewed`, while detailed records (store, IP, country, date) are in `product_report`. The 3.0 recurring payments (`product_recurring`) have been replaced by `product_subscription` with the key `(product_id, subscription_plan_id, customer_group_id)`.

## How to safely modify products from a module?

There are no foreign keys in the database in either 3.0 or 4.1, so integrity is maintained only by code. Deleting a product in the admin cleans up, besides `product`, the descriptions, attributes, categories, discounts, filters, images, options, [related products](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#related-products), points, stores, layouts, reviews, SEO URLs, and coupon links; in 4.1 also codes, reports, and subscriptions. A manual `DELETE FROM product` will leave all these rows behind.

- **Write through the admin model** `catalog/product`: `addProduct()`, `editProduct()`, `deleteProduct()`.
- **Remember that `editProduct()` overwrites related tables** with the data passed in. If you pass an array without images, the images will be deleted.
- **Clear the cache:** after changes, the admin model calls `$this->cache->delete('product')`; your direct query should do this too.
- **Do not add columns to `product`.** Keep your own fields in a separate module table with `product_id`; see [custom module tables in OpenCart](https://opencartcode.com/en/wiki/dev-extensions/opencart-module-tables).
- **Don't forget the SEO URL**: it is in `seo_url`, not in the product tables. The record format differs between 3.0 and 4.1, see [seo_url in OpenCart](https://opencartcode.com/en/wiki/dev-mvc/seo-url-opencart).

Bulk updating prices and stock from price lists is often easier to delegate to a ready-made module, for example [Automatic Price List Processing (AOP)](https://opencartcode.com/en/marketplace/product/avtomaticna-obrobka-prais-listiv-aop); how it works is described in the blog: [importing price lists into OpenCart](https://opencartcode.com/en/blog/import-prais-listiv-v-opencart-ogliad-modulia-aop).

## Summary

- `product` holds the price, stock, weight, and status; names are in `product_description` by language, categories in `product_to_category`, and visibility in `product_to_store`.
- The storefront shows a product only with status 1, a valid `date_available`, a row for the store, and a description in the current language.
- In 4.1, product codes are in `product_code`, specials in `product_discount` with `special = 1` and a value type, and variants with `master_id` and `override` have appeared.
- Write products through the `catalog/product` model and clear the `product` cache.

Tables for orders, customers, languages, and stores are covered in other articles in the [Database](https://opencartcode.com/en/wiki/dev-database) section. For how models work with the database, see the article [OpenCart model](https://opencartcode.com/en/wiki/dev-mvc/opencart-model).

## FAQ

**Why is the product in the admin but not showing on the site?**

Check the status, the date available, the product_to_store row for the required store, and the description for the current language. If everything is in place, check whether the product is linked to the category you are opening.

**Where is the product view count stored?**

In 3.0 it is in the product.viewed column, in 4.1 it is in the product_viewed table, and detailed view records are in product_report.

**Can several products have the same model?**

Yes, the model column has no unique key. If the SKU must be unique for import or warehouse use, check this in the module code.
