api - 将自定义产品属性添加到订单 API
问题描述
我通过添加了一个自定义属性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?
解决方案
推荐阅读
- amazon-web-services - 如何在 S3 java 中复制/下载文件的所有版本
- python - 使用 PCA (Python) 可视化集群结果
- azure - Azure Function - 时间触发函数状态
- c# - Quartz.NET cront 触发器设置为 23
- list - Dart 根据某个属性的值将列表拆分为子列表?
- javascript - SVG
带文本和 div 填充宽度,带过渡 - sql - 过滤分区内的值
- python-3.x - 无法使用 pip3 在 m1 mac 上使用 python3 安装 matplotlib
- android - 为什么应用链接会给华为带来额外的对话
- qt - cellClicked 和 cellPressed 不适用于 QTableWidget