I am missing the "insert widget" button on all WYSIWYG editors on the product edit pages. The magento guys seem to not have thought this through properly.
I found a way to add them to categories: How to add 'Insert Widget' functionality to category WYSIWYG editors in Magento 2 ?
Does anybody know how to add this button to product editors as well? Must be rocket science…
Best Answer
Here’s an example on how to do it for the Description field. You can use it for other WYSIWYG fields in the product edit page (just modify the condition for the IF in step number 2 and add the filter for the additional fields in step number 4).
The cleanest way to do it is by using plugins. You need two plugins, one to insert the button into the form and another to filter the content of the field to inject the widget content.
1) In a custom module, create a di.xml file for the adminhtml area and set a plugin to modify the form data provider:
[Vendor]/[ModuleName]/etc/adminhtml/di.xml
:2) Now create the plugin file to insert the button:
[Vendor]\[ModuleName]\Plugin\Ui\DataProvider\Product\Form\Modifier\Eav.php
:3) Create a di.xml file for the frontend area to set a plugin for the product view helper:
[Vendor]/[ModuleName]/etc/frontend/di.xml
:4) And finally, create the plugin file in the following path:
[Vendor]/[ModuleName]/Plugin/Helper/Product/View.php
: