我已通过 InstallData.php
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'hts_code',
[
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'HTS Code',
'input' => 'text',
'class' => '',
'source' => '',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => ''
]
);
}
它显示在每个产品的后端并且可以设置,没有问题。当我通过 REST API 查询产品时,它也是可见的。到目前为止很棒。
现在,我需要将此属性添加到 Order API 端点,以便在查询 Order 时,属性名称和值是可见的。
我遵循了此处的示例 https://magento.stackexchange.com/a/316609/38767 但它不起作用。
对于 Magento 2.3,我该如何将此自定义属性添加到 Order API?