I have a opengraph module installed. we have two product eav attributes og_title and og_desc. When I am adding a new product, i want og_title field to be autofilled to product title and og_desc to be autofilled to meta description.
I have included custom Js on new product page. and it autofills only if opengraph group is opened on a manual click as the fieldset appears after i manually open the group. Here is the code
catalog_product_new.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Test_Notifications::js/opengraphseocustom.js"/>
</head>
</page>
opengraphseocustom.js
require([
'jquery',
'uiRegistry',
'prototype'
], function ($, registry) {
//'use strict';
console.log("test");
$(document).ready(function () {
$(document).ajaxStop(function () {
var productTitleInput = registry.get('inputName = product[name]');
console.log(productTitleInput);
// Attach a custom event handler to capture changes
if (productTitleInput) {
}
$('div[data-index="open-graph-metadata"]').click();
$('input[name="product[name]"]').on('keyup' ,function () {
var title = $(this).val();
console.log("title" + title);
var ogTitleInput = $('input[name="product[og_title]"]');
ogTitleInput.val(title);
});
});
});
});
I want the og_title and og_desc field to be autofilled to title and meta description as i enter it in their respective fields without manually opening the opengraph group