Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

Magento 2的“产品编辑”页面中添加自定义字段

“我想在Magento 2的产品编辑页面中添加一些自定义字段 ”。当您希望在页面上使用默认系统不包含的额外信息时,我认为这是非常重要的要求。如果您还遇到这个问题,这里有适合您的解决方案。今天的帖子提供了两个步骤来跟踪在Magento 2中的产品编辑页面中添加自定义字段的成功过程。

在Magento 2的“产品编辑”页面中添加自定义字段的概述

  • 第1步:生成UI组件
  • 第2步:Manage Notes在“产品”表单中插入部分(product_form.xml

第1步:生成UI组件

在模块中运行该命令以生成UI组件

/app/code/Mageplaza/HelloWorld/view/adminhtml/ui_component/product_form.xml

第2步:Manage Notes在“产品”表单中插入部分(product_form.xml

要插入Manage Notes部分,请执行以下操作:

  • 使用代码段:
<?xml version="1.0" encoding="UTF-8"?>

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">   
<modal name="advanced_inventory_modal">  
     <fieldset name="manage_note">
         <argument name="data" xsi:type="array">        
             <item name="config" xsi:type="array">
                 <item name="label" xsi:type="string" translate="true">Manage Note</item>
                 <item name="dataScope" xsi:type="string"/>
                 <item name="sortOrder" xsi:type="number">0</item>
                 <item name="collapsible" xsi:type="boolean">true</item>
                 <item name="opened" xsi:type="boolean">true</item>
             </item>
         </argument>
         <field name="note">
             <argument name="data" xsi:type="array">
                 <item name="config" xsi:type="array">
                     <item name="label" xsi:type="string" translate="true">Notes</item>
                     <item name="formElement" xsi:type="string">textarea</item>
                     <item name="dataScope" xsi:type="string">quantity_and_stock_status.note</item>
                     <item name="sortOrder" xsi:type="number">1</item>
                     <item name="scopeLabel" xsi:type="string">[GLOBAL]</item>
                 </item>
             </argument>
         </field>          
     </fieldset>
     <fieldset name="stock_data">
         <argument name="data" xsi:type="array">
             <item name="config" xsi:type="array">
                 <item name="label" xsi:type="string" translate="true">Stock Configuration</item>
                 <item name="dataScope" xsi:type="string"/>
                 <item name="sortOrder" xsi:type="number">100</item>
                 <item name="collapsible" xsi:type="boolean">true</item>
             </item>
         </argument>
     </fieldset>   
</modal>
</form>
  • note将类型为Textarea 的字段插入manage_note 字段集(<field name="note">),该字段集应用于将Fieldset manage_note插入Product表单(<fieldset name="manage_note">
  • 启用此自定义模块,然后登录后端以编辑产品。注释字段将显示在“产品”表单中。

通过本教程,我相信当您需要在Magento 2的“产品编辑”页面中添加自定义字段时,一切都会轻而易举。

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论