How to reduce product description and short description input field height in the backend?
-
14-04-2021 - |
Solution
Write a plugin on WysiwygConfigDataProcessor::process()
method. The methods return wysiwyg parameters for admin product form.
- Create your own module
- Declare your plugin (app/code/Vendor/Module/etc/adminhtml/di.xml):
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav\WysiwygConfigDataProcessor">
<plugin name="changeProductFormWysiwygSize" type="Vendor\Module\Plugin\WysiwygConfigData" />
</type>
</config>
- Code of the plugin (app/code/Vendor/Module/Plugin/WysiwygConfigData.php):
<?php
declare(strict_types=1);
namespace Vendor\Module\Plugin;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav\WysiwygConfigDataProcessor;
class WysiwygConfigData
{
/**
* @param WysiwygConfigDataProcessor $subject
* @param array $result
* @param ProductAttributeInterface $attribute
*
* @return array
*/
public function afterProcess(
WysiwygConfigDataProcessor $subject,
array $result,
ProductAttributeInterface $attribute
): array {
if (in_array($attribute->getAttributeCode(), ['description', 'short_description'])) {
$result['height'] = '150px'; // Change this value to set your size
}
return $result;
}
}
- Run
setup:upgrade
command to apply the code and module.
Hope this helps
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange