<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Marketplace
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */

/** @var $block \Webkul\Marketplace\Block\Product\Create */

$helper = $this->helper(\Webkul\Marketplace\Helper\Data::class);
$product_hint_status = $helper->getProductHintStatus();
$currency_code = $helper->getCurrentCurrencyCode();
$currency_symbol = $helper->getCurrencySymbol();
$product_id = $this->getRequest()->getParam('id');
$product_coll = $block->getProduct($product_id);
$websiteIds= $product_coll->getWebsiteIds();
$attribute_set_id = $product_coll['attribute_set_id'];
if ($this->getRequest()->getParam('set')) {
    $attribute_set_id = $this->getRequest()->getParam('set');
}
$skuType = $helper->getSkuType();
$weightUnit = $helper->getWeightUnit();
?>
<form action="<?= $block->escapeUrl($block->getUrl('marketplace/product/save', ['_secure' => $this->getRequest()->isSecure()])) ?>" enctype="multipart/form-data" method="post" id="edit-product" data-form="edit-product" data-mage-init='{"validation":{}}'>
    <div class="wk-mp-design" id="wk-bodymain">
        <fieldset class="fieldset info wk-mp-fieldset">
            <div data-mage-init='{"formButtonAction": {}}' class="wk-mp-page-title legend">
                <span><?= $block->escapeHtml(__('Edit Product')) ?></span>
                <button class="button wk-mp-btn" title="<?= $block->escapeHtml(__('Save')) ?>" type="submit" id="save-btn">
                    <span><span><?= $block->escapeHtml(__('Save')) ?></span></span>
                </button>
                <button class="button wk-mp-btn" title="<?= $block->escapeHtml(__('Save & Duplicate')) ?>" type="button" id="wk-mp-save-duplicate-btn">
                    <span><span><?= $block->escapeHtml(__('Save & Duplicate')) ?></span></span>
                </button>
            </div>
            <?= $block->getBlockHtml('formkey')?>
            <?= $block->getBlockHtml('seller.formkey')?>
            <input id="product_type_id" name="type" type="hidden" value="<?= /* @noEscape */ $product_coll['type_id']?>">
            <input type="hidden" name="id" value="<?= /* @noEscape */ $product_id; ?>" />
            <input type="hidden" name="product_id" value="<?= /* @noEscape */ $product_id; ?>" />
            <?php if (count($helper->getAllowedSets()) > 1) { ?>
                <div class="field required">
                    <label class="label"><?= $block->escapeHtml(__('Attribute Set')) ?>:</label>
                    <div class="control">
                        <select name="set" id="attribute-set-id"  class="required-entry">
                        <?php foreach ($helper->getAllowedSets() as $set) {?>
                            <option value="<?= $set['value'] ?>" <?php if ($attribute_set_id==$set['value']) { ?> selected="selected" <?php } ?>><?= /* @noEscape */ $set['label']?></option>
                        <?php } ?>
                        </select>
                    </div>
                </div>
                <?php
            } else {
                $allowedSets = $helper->getAllowedSets();
                if (!empty($allowedSets)) { ?>
                    <input type="hidden" name="set" id="attribute-set-id" value="<?= /* @noEscape */ $allowedSets[0]['value'] ?>" />
                    <?php
                } else { ?>
                    <input type="hidden" name="set" id="attribute-set-id" value="<?= /* @noEscape */ $attribute_set_id ?>" />
                    <?php
                }
            } ?>
            <div class="field">
                <label class="label"><?= $block->escapeHtml(__('Product Category')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintCategory()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintCategory()) ?>"/>
                    <?php
                } ?>
                
                <?php if ($helper->getIsAdminViewCategoryTree()) { ?>
                    <div data-bind="scope: 'sellerCategory'">
                        <!-- ko template: getTemplate() --><!-- /ko -->
                    </div>
                    <?php $categories = $product_coll->getCategoryIds();?>
                    <script type="text/x-magento-init">
                        {
                            "*": {
                                "Magento_Ui/js/core/app": {
                                    "components": {
                                        "sellerCategory": {
                                            "component": "Webkul_Marketplace/js/product/seller-category-tree",
                                            "template" : "Webkul_Marketplace/seller-category-tree",
                                            "filterOptions": true,
                                            "levelsVisibility": "1",
                                            "options": <?= /* @noEscape */ $block->getCategoriesTree()?>,
                                            "value": <?= /* @noEscape */ json_encode($categories)?>
                                        }
                                    }
                                }
                            }
                        }
                    </script>
                <?php } else { ?>
                    <div class="wk-field wk-category">
                        <div class="wk-for-validation">
                            <div id="wk-category-label"><?= $block->escapeHtml(__("CATEGORIES")); ?></div>
                            <?php
                            $categories = $product_coll->getCategoryIds();
                            $cat_ids=implode(",", $categories);
                            foreach ($categories as $value) {
                                ?>
                                <input type="hidden" name="product[category_ids][]" value="<?= /* @noEscape */ $value; ?>" id="wk-cat-hide<?= /* @noEscape */ $value; ?>"/>
                                <?php
                            }
                            ?>
                            <?php
                            if ($helper->getAllowedCategoryIds()) {
                                $storeconfig_catids = explode(',', trim($helper->getAllowedCategoryIds()));
                                foreach ($storeconfig_catids as $storeconfig_catid) {
                                    $cat_model = $block->getCategory()->load($storeconfig_catid);
                                    if (isset($cat_model["entity_id"]) && $cat_model["entity_id"]) {
                                        ?>
                                        <div class="wk-cat-container">
                                            </span><span class="wk-foldersign"></span>
                                            <span class="wk-elements wk-cat-name"><?= $block->escapeHtml($cat_model->getName()) ?></span>
                                            <?php
                                            if (in_array($cat_model["entity_id"], $categories)) {?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value=<?= /* @noEscape */ $cat_model['entity_id'] ?> checked />
                                                <?php
                                            } else { ?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value='<?= /* @noEscape */ $cat_model['entity_id'] ?>'/>
                                            <?php
                                            } ?>
                                        </div>
                                        <?php
                                    }
                                }
                            } else {
                                $count = 0;
                                $category_helper = $this->helper(\Magento\Catalog\Helper\Category::class);
                                $category_model = $block->getCategory();
                                $_categories = $category_helper->getStoreCategories();
                                foreach ($_categories as $_category) {
                                    $count++;
                                    if (count($category_model->getAllChildren($category_model->load($_category['entity_id'])))-1 > 0) { ?>
                                        <div class="wk-cat-container" style="margin-left:0px;">
                                            <span class="wk-plus">
                                            </span><span class="wk-foldersign"></span>
                                            <span class="wk-elements wk-cat-name"><?= $block->escapeHtml($_category->getName()) ?></span>
                                            <?php
                                            if (in_array($_category["entity_id"], $categories)) {?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value=<?= $block->escapeHtml($_category['entity_id']) ?> checked />
                                                <?php
                                            } else { ?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value='<?= $block->escapeHtml($_category['entity_id']) ?>'/>
                                                <?php
                                            } ?>
                                        </div>
                                        <?php
                                    } else { ?>
                                        <div class="wk-cat-container">
                                            </span><span class="wk-foldersign"></span>
                                            <span class="wk-elements wk-cat-name"><?= $block->escapeHtml($_category->getName()) ?></span>
                                            <?php
                                            if (in_array($_category["entity_id"], $categories)) {?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value=<?= $block->escapeHtml($_category['entity_id']) ?> checked />
                                                <?php
                                            } else { ?>
                                                <input class="wk-elements" type="checkbox" name="product[category_ids][]" value='<?= $block->escapeHtml($_category['entity_id']) ?>'/>
                                                <?php
                                            } ?>
                                        </div>
                                        <?php
                                    }
                                }
                            } ?>
                        </div>
                    </div>
                <?php } ?>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Product Name')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintName()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintName()) ?>"/>
                    <?php
                } ?>
                <div class="control">
                    <input type="text" class="required-entry input-text" name="product[name]" id="name" value="<?= $block->escapeHtml($product_coll->getName()); ?>"/>
                </div>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Description')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintDesc()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintDesc()) ?>"/>
                    <?php
                } ?>
                <div class="control wk-border-box-sizing">
                    <textarea name="product[description]" class="required-entry input-text" id="description" rows="5" cols="75" ><?= /* @noEscape */ $product_coll->getDescription(); ?></textarea>
                    <?php if ($helper->isWysiwygEnabled()): ?>
                        <script>
                            require([
                                "jquery",
                                "mage/translate",
                                "mage/adminhtml/events",
                                "mage/adminhtml/wysiwyg/tiny_mce/setup"
                            ], function(jQuery) {
                                wysiwygDescription = new wysiwygSetup("description", {
                                    "width" : "100%",
                                    "height" : "200px",
                                    "plugins" : [{"name":"image"}],
                                    "tinymce4" : {
                                        "toolbar":"formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap","plugins":"advlist autolink lists link charmap media noneditable table contextmenu paste code help table",
                                    },
                                    files_browser_window_url: "<?= $block->getWysiwygUrl();?>"
                                });
                                wysiwygDescription.setup("exact");
                            });
                        </script>
                    <?php endif; ?>
                </div>
            </div>
            <div class="field">
                <label class="label"><?= $block->escapeHtml(__('Short Description')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintShortDesc()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= /* @noEscape */ $helper->getProductHintShortDesc() ?>"/>
                    <?php
                } ?>
                <div class="control wk-border-box-sizing">
                    <textarea name="product[short_description]" class="input-text" id="short_description" rows="5" cols="75" ><?= /* @noEscape */ $product_coll->getShortDescription(); ?></textarea>
                    <?php if ($helper->isWysiwygEnabled()): ?>
                        <script>
                            require([
                                "jquery",
                                "mage/translate",
                                "mage/adminhtml/events",
                                "mage/adminhtml/wysiwyg/tiny_mce/setup"
                            ], function(jQuery) {
                                wysiwygShortDescription = new wysiwygSetup("short_description", {
                                    "width" : "100%",
                                    "height" : "200px",
                                    "plugins" : [{"name":"image"}],
                                    "tinymce4" : {
                                        "toolbar":"formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap","plugins":"advlist autolink lists link charmap media noneditable table contextmenu paste code help table",
                                    },
                                    files_browser_window_url: "<?= $block->getWysiwygUrl();?>"
                                });
                                wysiwygShortDescription.setup("exact");
                            });
                        </script>
                    <?php endif; ?>
                </div>
            </div>
            <?php
            $mpProStatus = 0;
            $mpProColl = $helper->getSellerProductDataByProductId($product_id);
            foreach ($mpProColl as $key => $value) {
                $mpProStatus = $value['status'];
            }
            if (!$helper->getIsProductEditApproval() && $mpProStatus==1) { ?>
                <div class="field required">
                    <label class="label"><?= $block->escapeHtml(__('Status')) ?>:</label>
                    <?php
                    if ($product_hint_status && $helper->getProductHintEnable()) {?>
                        <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintStatus()) ?>"/>
                        <?php
                    } ?>
                    <div class="control">
                        <input type="radio" name="status" id="status1" value="1" <?php if ($product_coll->getStatus()==1) { echo 'checked="checked"'; } ?>/><?= $block->escapeHtml(__("Enable")); ?><br>
                        <input type="radio" name="status" id="status2" value="2" <?php if ($product_coll->getStatus()==2) { echo 'checked="checked"'; } ?>/><?= $block->escapeHtml(__("Disable")); ?>
                    </div>
                </div>
                <?php
            } ?>
            <?php
            if ($skuType == 'static') { ?>
                <div class="field required">
                    <label class="label"><?= $block->escapeHtml(__('SKU')) ?>:</label>
                    <?php
                    if ($product_hint_status && $helper->getProductHintSku()) {?>
                        <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintSku()) ?>"/>
                        <?php
                    } ?>
                    <div class="control">
                        <input name="product[sku]" id="sku" class="required-entry validate-length maximum-length-64 input-text" type="text" value="<?= $block->escapeHtml($product_coll->getsku()); ?>"/>
                    </div>
                    <div id="skuavail" >
                        <span class="success-msg skuavailable"><?= $block->escapeHtml(__('SKU Available')) ?></span>
                    </div>
                    <div id="skunotavail" >
                        <span class="error-msg skunotavailable"><?= $block->escapeHtml(__('SKU Already Exist')) ?></span>
                    </div>
                </div>
                <?php
            } ?>
            <div class="field required <?php if ($product_coll['type_id']=='configurable') { ?> no-display <?php } ?>">
                <label class="label"><?= $block->escapeHtml(__('Price')) ?><b><?= " (".$currency_symbol.")"; ?></b>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintPrice()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintPrice()) ?>"/>
                        <?php
                } ?>
                <div class="control">
                    <input type="text" class="required-entry validate-zero-or-greater input-text" name="product[price]" id="price" value="<?= /* @noEscape */ $product_coll->getPrice() ?>" data-ui-id="product-tabs-attributes-tab-fieldset-element-text-product-price"/>
                </div>
            </div>
            <?php if ($product_coll['type_id']!='configurable') { ?>
                <div class="field">
                    <label class="label"><?= $block->escapeHtml(__('Special Price')) ?><b><?=  " (".$currency_symbol.")"; ?></b>:</label>
                    <?php
                    if ($product_hint_status && $helper->getProductHintSpecialPrice()) {?>
                        <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintSpecialPrice()) ?>"/>
                    <?php
                    } ?>
                    <div class="control">
                        <input type="text" class="widthinput input-text validate-zero-or-greater" name="product[special_price]" id="special-price" value="<?= /* @noEscape */ $product_coll->getSpecialPrice() ?>"/>
                    </div>
                </div>
                <div class="field">
                    <label class="label"><?= $block->escapeHtml(__('Special Price From')) ?>:</label>
                    <?php
                    if ($product_hint_status && $helper->getProductHintStartDate()) {?>
                        <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintStartDate()) ?>"/>
                        <?php
                    } ?>
                    <?php
                    if ($product_coll->getData('special_from_date')) {
                        $special_from_date = $block->formatDate($product_coll->getData('special_from_date'));
                    } else {
                        $special_from_date = '';
                    } ?>
                    <div class="control">
                        <input type="text" name="product[special_from_date]" id="special-from-date" class="input-text" value="<?= /* @noEscape */ $special_from_date; ?>"/>
                    </div>
                </div>
                <div class="field">
                    <label class="label"><?= $block->escapeHtml(__('Special Price To')) ?>:</label>
                    <?php
                    if ($product_hint_status && $helper->getProductHintEndDate()) {?>
                        <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintEndDate()) ?>"/>
                        <?php
                    } ?>
                    <?php
                    if ($product_coll->getData('special_to_date')) {
                        $special_to_date = $block->formatDate($product_coll->getData('special_to_date'));
                    } else {
                        $special_to_date = '';
                    } ?>
                    <div class="control">
                        <input type="text" name="product[special_to_date]" id="special-to-date" class="input-text" value="<?= /* @noEscape */ $special_to_date; ?>" />
                    </div>
                </div>
                <?php
            } ?>
            <input id="inventory_manage_stock" type="hidden" name="product[stock_data][manage_stock]" value="1">
            <input type="hidden" value="1" name="product[stock_data][use_config_manage_stock]" id="inventory_use_config_manage_stock">
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Stock')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintQty()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintQty()) ?>"/>
                    <?php
                } ?>
                <div class="control">
                    <input type="text" class="required-entry validate-number input-text" name="product[quantity_and_stock_status][qty]" id="qty" value="<?= /* @noEscape */ $product_coll['quantity_and_stock_status']['qty'] ?>"/>
                </div>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Stock Availability')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintStock()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintStock()) ?>"/>
                    <?php
                } ?>
                <?php
                $is_in_stock = $product_coll['quantity_and_stock_status']['is_in_stock'];
                ?>
                <div class="control">
                    <select id="" class="select" name="product[quantity_and_stock_status][is_in_stock]">
                        <option <?php if ($is_in_stock==1) { echo "selected"; } ?> value="1"><?= $block->escapeHtml(__("In Stock")); ?></option>
                        <option <?php if ($is_in_stock==0) { echo "selected"; } ?> value="0"><?= $block->escapeHtml(__("Out of Stock")); ?></option>
                    </select>
                </div>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Visibility')) ?>:</label>
                <div class="control">
                    <select id="visibility" class=" required-entry required-entry select" name="product[visibility]">
                        <option value=""><?= $block->escapeHtml(__('Please Select'))?></option>
                        <?php
                        $product_visibility = $helper->getVisibilityOptionArray();
                        foreach ($product_visibility as $key => $value) {
                            ?>
                            <option value="<?= $key ?>" <?php if ($key==$product_coll->getVisibility()) { echo "selected='selected'";}?>><?= $value?></option>
                            <?php
                        } ?>
                    </select>
                </div>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Tax Class')) ?>:</label>
                <?php
                if ($product_hint_status && $helper->getProductHintTax()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintTax()) ?>"/>
                    <?php
                } ?>
                <div class="control">
                    <select id="tax-class-id" class="required-entry required-entry select" name="product[tax_class_id]">
                        <option value="0"><?= $block->escapeHtml(__('None'))?></option>
                        <?php
                        $taxid=$product_coll->getData('tax_class_id');
                        $taxes=$helper->getTaxClassModel();
                        foreach ($taxes as $tax) {
                            ?>
                            <option <?= $taxid==$tax->getId()? 'selected':''; ?> value="<?= $block->escapeHtml($tax->getId()) ?>"><?= $block->escapeHtml($tax->getClassName())?></option>
                            <?php
                        } ?>
                    </select>
                </div>
            </div>
            <div class="field required">
                <label class="label"><?= $block->escapeHtml(__('Weight')) ?> (<?= $block->escapeHtml($weightUnit)?>):</label>
                <?php
                if ($product_hint_status && $helper->getProductHintWeight()) {?>
                    <img src="<?= $block->escapeUrl($this->getViewFileUrl('Webkul_Marketplace::images/quest.png')); ?>" class='questimg' title="<?= $block->escapeHtml($helper->getProductHintWeight()) ?>"/>
                    <?php
                } ?>
                <div data-role="weight-switcher">
                    <label data-ui-id="product-tabs-attributes-tab-element-radios-product-product-has-weight-label" for="weight-switcher">
                        <span><?= $block->escapeHtml(__('Does this have a weight?'))?></span>
                    </label>
                    <div class="control">
                        <div class="control">
                            <input type="radio" <?php if ($product_coll['type_id']=='simple' || ($product_coll['type_id']=='configurable' && !empty($product_coll['weight']))) { ?>checked="checked" <?php } ?> class="weight-switcher" id="weight-switcher1" value="1" name="product[product_has_weight]">
                            <label for="weight-switcher1">
                                <span><?= $block->escapeHtml(__('Yes'))?></span>
                            </label>
                        </div>
                        <div class="control">
                            <input type="radio" <?php if ($product_coll['type_id'] == 'downloadable' || $product_coll['type_id'] == 'virtual' || ($product_coll['type_id']=='configurable' && empty($product_coll['weight']))) { ?>checked="checked" <?php } ?> class="weight-switcher" id="weight-switcher0" value="0" name="product[product_has_weight]">
                            <label for="weight-switcher0">
                                <span><?= $block->escapeHtml(__('No'))?></span>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="control">
                    <input type="text" class="validate-zero-or-greater input-text" name="product[weight]" id="weight" value="<?= $block->escapeHtml($product_coll->getWeight());?>" <?php if ($product_coll['type_id'] == 'downloadable' || $product_coll['type_id'] == 'virtual') { ?>disabled="disabled" <?php } ?>/>
                </div>
            </div>
            <div class="field">
            <label class="label"><?= $block->escapeHtml(__('Url Key')) ?>:</label>
                <div class="control">
                    <input type="text" class="input-text" name="product[url_key]" id="url_key" value="<?= $block->escapeHtml($product_coll['url_key']) ?>"/>
                </div>
            </div>
            <?php if(!$helper->getCustomerSharePerWebsite()): ?>
                <div class="field required">
                    <label class="label"><?= $block->escapeHtml(__('Product in Websites')) ?>:</label>
                    <div class="control">
                        <select id="websites" class="required-entry select" name="product[website_ids][]" multiple>
                            <?php $websites = $helper->getAllWebsites(); ?>
                            <?php foreach ($websites as $website): ?>
                                <option value="<?= /* @noEscape */ $website->getWebsiteId() ?>"
                                <?= in_array($website->getWebsiteId(),$websiteIds)? 'selected':''; ?>  ><?=  /* @noEscape */ $website->getName()?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
            <?php endif; ?>
            <div class="field">
                <label class="label"><?= $block->escapeHtml(__('Meta Title')) ?>:</label>
                <div class="control">
                    <input type="text" class="input-text" name="product[meta_title]" id="meta_title" value="<?= $block->escapeHtml($product_coll['meta_title']) ?>"/>
                </div>
            </div>
            <div class="field">
                <label class="label"><?= $block->escapeHtml(__('Meta Keywords')) ?>:</label>
                <div class="control">
                    <textarea class="textarea" id="meta_keyword" name="product[meta_keyword]"><?= $block->escapeHtml($product_coll['meta_keyword']) ?></textarea>
                </div>
            </div>
            <div class="field">
                <label class="label"><?= $block->escapeHtml(__('Meta Description')) ?>:</label>
                <div class="control">
                    <textarea class="textarea" id="meta_description" name="product[meta_description]"><?= $block->escapeHtml($product_coll['meta_description']) ?></textarea>
                </div>
            </div>
            <?= $block->getChildHtml(); ?>
        </fieldset>
    </div>
</form>
<?php
$formData = [
    'productTypeId' => $product_coll['type_id'],
    'categories' => implode(',', $categories),
    'countryPicSelector' => '#country-pic',
    'verifySkuAjaxUrl' => $block->getUrl('marketplace/product/verifysku', ['_secure' => $this->getRequest()->isSecure()]),
    'productid'  => $product_id,
    'categoryTreeAjaxUrl' => $block->getUrl('marketplace/product/categorytree/', ['_secure' => $this->getRequest()->isSecure()])
];
$serializedFormData = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($formData);
?>

<script type="text/x-magento-init">
    {
        "*": {
            "sellerEditProduct": <?= /* @noEscape */ $serializedFormData; ?>
        }
    }
</script>
<script type='text/javascript'>
    require(['jquery', 'prototype', 'domReady!'], function($) {
        var qty = $('#qty'),
            productType = $('#product_type_id').val(),
            stockAvailabilityField = $('#quantity_and_stock_status'),
            manageStockField = $('#inventory_manage_stock'),
            useConfigManageStockField = $('#inventory_use_config_manage_stock'),
            fieldsAssociations = {
                'qty': 'inventory_qty',
                'quantity_and_stock_status': 'inventory_stock_availability'
            };

        var qtyDefaultValue = qty.val();
    })
</script>
<script>
    require([
        "jquery",
        "Webkul_Marketplace/catalog/type-events"
    ], function($, TypeSwitcher){
        var $form = $('[data-form=edit-product]');
        $form.data('typeSwitcher', TypeSwitcher.init());
    });
</script>
<script type="text/x-magento-init">
    {
        "*": {
            "Webkul_Marketplace/js/product/weight-handler": {},
            "Webkul_Marketplace/catalog/apply-to-type-switcher": {}
        }
    }
</script>
