CMS Page with the same ID already exists error
Problem
After installation of Klevu and API key integration, some stores may experience the following error when running sync operations, or saving CMS pages:
Item (Magento\Cms\Model\Page) with the same ID "{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

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
$select->group('main_table.page_id');The block should look like this after (code correct at module v3.1.1)
// 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