cancel
Showing results for 
Search instead for 
Did you mean: 

Skip saving custom options during product edit

Skip saving custom options during product edit

Hello, 

 

Our store runs with mostly unique one of a kind products. Each product has about 20 custom option fields, each with 20 options in per drop down. Each custom option also has logic attached to show or not. This results in a pretty large object.

 

This is all fine for product creation. but our admins sometimes have to edit products to adjust price, or turn add some attributes and what not. When this happens they must save the product that they are editing and that takes about 2-3 minutes per product to save. I'm looking for a way to circumvent saving the custom options inside of the product object. I have already added a workaround to skip options during the validation step of saving which shaved off some time, but I was wondering if there was any tricks I could use to prevent the options from being saved at all, especially if the product edits do not have anything to do with the options at all.

 

Thanks

1 REPLY 1

Re: Skip saving custom options during product edit

There are ways to significantly improve performance. One approach is to modify the admin product data provider to skip loading the custom options entirely unless needed. This can be done by creating a plugin on Magento’s ProductDataProvider::afterGetData() method to unset or remove the custom options field from the returned data. This prevents the admin form from unnecessarily loading large option sets, which helps speed up both loading and saving processes. Additionally, you can create a plugin for the product resource model’s beforeSave() method to check whether the custom options were modified. If they weren’t, you can programmatically set the can_save_custom_options flag to false. This tells Magento to completely skip saving the options for that product, avoiding the performance overhead when they're not needed. These two techniques together skipping both loading and saving of custom options can greatly reduce the time it takes to save a tuxedos product, especially in stores with large, dynamic custom option structures.