I want to strip all bundle options from a bundle product when it loads except the first one. To give this some context, I have products with upwards of 20 options, each containing the same set of products. This means the form contains literally thousands of fields. I was working around it by increasing php max_input_vars but when that topped 10,000 and still failed saving one of the largest products I figured it was getting stupid.
At the moment, when saving a bundle product I've attached a function to the save handler which copies the first bundle option and applies it to the remaining option. I plan to add a number input field which specifies the number of bundle options instead of adding the options manually, but that's for another time.
The problem is, I don't know where to begin to find out where I can intercept the product loading and strip out the options I don't want. Obviously when the product has loaded I only want the UI to show one bundle option with the quantity field, not loads of identical bundle options.
To top that off, if you try to save a bundle product which has more than 20 options the table paginates. If you don't make any changes and try to save it throws an error. There's an issue about it on GitHub here: https://github.com/magento/magento2/issues/6916
So, which Controller file can I override so that when a Bundle product is loading I can remove all but one of the bundle options?