Skip to content

Add multishop overwrite confirmation when editing categories in all-shops context#65

Open
therampagerado wants to merge 1 commit intocategories-multistore-fields-overwrite-checkfrom
codex/add-warning-for-category-save-conflicts-5a45su
Open

Add multishop overwrite confirmation when editing categories in all-shops context#65
therampagerado wants to merge 1 commit intocategories-multistore-fields-overwrite-checkfrom
codex/add-warning-for-category-save-conflicts-5a45su

Conversation

@therampagerado
Copy link
Copy Markdown
Owner

Motivation

  • Prevent accidental overwrites of per-shop category text fields when saving a category in the all-shops context by prompting the merchant with overwrite choices.
  • Provide options to either overwrite values for all shops, only populate empty shop values, or cancel the save to avoid data loss across shops.

Description

  • Add overwrite flow to AdminCategoriesControllerCore by introducing MULTISHOP_OVERWRITE_ACTION_* constants, a multishopOverwriteData holder, and an override of processUpdate() that detects per-shop differences via getMultishopOverwriteDifferences() and shows the form again when differences exist.
  • Implement helper methods shouldCheckMultishopOverwrite(), getMultishopTextFields(), getAssociatedShopIds(), getMultishopCategoryLangValues(), restoreNonEmptyMultishopValues() and isMultishopValueEmpty() to identify changed text fields and to support the overwrite_empty behavior which preserves non-empty shop-specific values.
  • Populate the template variable multishop_overwrite in the controller so the form layer can render UI, and add a hidden multishop_overwrite_action field plus a Bootstrap modal and JS in admin-dev/themes/default/template/helpers/form/form.tpl that intercepts submits and offers the merchant three choices: Save for all shops, Save only empty values, or Cancel.
  • When overwrite_empty is chosen the controller saves the posted values and then restores previously non-empty per-shop values so only empty fields are filled from the all-shops submission.

Testing

  • No automated tests were executed for this change (no test run was requested).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8ae972b47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +875 to +879
$('#multishop-overwrite-confirm-all').on('click', function () {
isSubmitting = true;
$action.val('overwrite_all');
$form.submit();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve clicked submit action when confirming overwrite

When the modal confirmation triggers, the handler calls $form.submit() programmatically, which does not include the originally clicked submit button name/value. As a result, if the user clicked "Save and stay" or "Save and back to parent" the POST no longer contains submitAddCategoryAndStay (or similar), so the controller treats it as a normal save and redirects differently. This regression only happens when the overwrite modal is shown; consider capturing the clicked submit button (or adding a hidden field) and re‑submitting that action along with multishop_overwrite_action.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant