magento2-configurator
magento2-configurator copied to clipboard
Can't update cms pages with is_active = 0
If a cms page is defined as follows:
my-test-page:
page:
-
source: app/configurator/common/pages/content/my-test-page.html
title: My Test Page
page_layout: 1column
meta_keywords:
meta_description:
content_heading:
is_active: 0
sort_order: 0
layout_update_xml:
custom_theme:
custom_root_template:
custom_layout_update_xml:
custom_theme_from:
custom_theme_to:
meta_title:
then re-running the configurator to update the content will fail with:
Could not save the page: URL key for specified store already exists.
The reason is here: https://github.com/ctidigital/magento2-configurator/blob/develop/Component/Pages.php#L101
This calls checkIdentifier: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Cms/Model/ResourceModel/Page.php#L276 - which hardcodes a value of 1
for isActive
.
Therefore a query like the following is generated:
SELECT `cp`.`page_id` FROM `cms_page` AS `cp`
INNER JOIN `cms_page_store` AS `cps` ON cp.row_id = cps.row_id WHERE ((cp.identifier = 'my-test-page') AND (cps.store_id IN (0, 0)) AND (cp.is_active = 1)) AND (cp.created_in <= 1) AND (cp.updated_in > 1) ORDER BY `cps`.`store_id` DESC
LIMIT 1
with is_active = 1 the page is not found, and configurator therefore tries to create it instead of update it.