-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
Description
Summary
When a ProductPage is unpublished or deleted, all associated OptionItem records are permanently destroyed. Since OptionItem is an unversioned DataObject, this data loss is irreversible without a database backup.
Root Cause
ProductPage::onBeforeDelete() contains logic that checks $this->Status != 'Published' and then deletes all ProductOptions:
public function onBeforeDelete()
{
if ($this->Status != 'Published') {
if ($this->ProductOptions()) {
$options = $this->getComponents('ProductOptions');
foreach ($options as $option) {
$option->delete();
}
}
}
parent::onBeforeDelete();
}Problems
$this->Statusis a legacy SS3 property — it doesn't exist reliably in SS4/SS5's versioning model, so the condition evaluates totruealmost alwaysOptionItemis unversioned — once deleted, there's no recoveryOptionItemhas abelongs_many_manytoOrderDetail— deleting options also corrupts historical order records- Even just deleting the draft version of a page fires
onBeforeDelete, nuking all options
Impact
- All product options (color, size, type, etc.) are permanently lost
- Historical order data is corrupted (can't determine what customers purchased)
- No recovery path without database backup
Proposed Fix
- Remove the destructive
onBeforeDeletefromProductPage - Add
Versionedextension toOptionItemso options follow the same draft/live lifecycle as pages - Add a protective
onBeforeDeleteguard onOptionItemto prevent deletion of options linked to orders - Create a
BuildTaskto publish all existingOptionItemrecords (data migration)
Reactions are currently unavailable