---
title: CMS Page with the same ID already exists error
slug: klevu-magento-v4/cms-page-with-the-same-id-already-exists-error
docTags: 
createdAt: 2025-09-11T09:21:39.917Z
---

# Problem

After installation of Klevu and API key integration, some stores may experience the following error when running sync operations, or saving CMS pages:

:::hint{type="danger"}
Item (Magento\Cms\Model\Page) with the same ID "&#x7B;id}" already exists
:::

# Cause

The root cause of this is an unexpected CMS Page -> Store View configuration and how that conflicts with the way Klevu collects pages to process.

Klevu will attempt to retrieve all records which belong to *either* All Store Views or the specific store being synchronised. Where a CMS page has been redundantly assigned to both All Store Views and the store view being synced, duplicate records may be picked up by Klevu.

An example of this configuration is below

![](https://api.archbee.com/api/optimize/txIf3IazdJsdQky_oYUyV-JPO90vXLQttmvDeR-ZLaJ-20250911-142022.png)

# Solution

Update your store's configuration to assign problematic CMS pages (the database ID is provided in the error message) to be assigned to *either* All Store Views or specific stores.

If you have database access, you can check the `cms_page_store` table to find duplicate `page_id` rows where at least one row has a `store_id` of `0`

## Workaround

If are unable to resolve the configuration, you can create a small patch for the `klevu/module-v4-indexing-cms` module.

In the `Klevu\IndexingCms\Service\Provider\CmsEntityProvider::getPageCollection` , look for the modifications made to the `$pageCollection` database select when a `$store` value is passed.
At the end of this block, add the following line

```php
$select->group('main_table.page_id');
```

Ref: [CmsEntityProvider @ 3.1.1 on Github](https://github.com/klevu/module-m2-indexing-cms/blob/3.1.1/Service/Provider/CmsEntityProvider.php#L174)

The block should look like this after (code correct at module v3.1.1)

```php
// snip
        if ($store) {
            $connection = $pageCollection->getConnection();
            $select = $pageCollection->getSelect();
            $select->joinInner(
                name: ['store' => $pageCollection->getTable('cms_page_store')],
                cond: implode(
                    ' ' . Select::SQL_AND . ' ',
                    [
                        sprintf(
                            'main_table.page_id = store.%s',
                            $connection->quoteIdentifier($linkField),
                        ),
                        $connection->quoteInto('store.store_id IN (0,?)', (int)$store->getId()),
                    ],
                ),
                cols: ['store.store_id'],
            );
            $select->group('main_table.page_id');
        }
// snip
```





