WP All Import/WordPress下获取节点名称及产品类型映射求助
WP All Import 处理嵌套product_type节点的脚本方案
获取节点名称
在WP All Import的字段映射中,使用自定义PHP脚本可直接获取<product_type>节点的名称:
$node_name = $xml->getName(); echo $node_name;
执行后会输出节点标签名product_type。
获取产品类型值
如果产品类型值存储在<product_type>下的<reference>节点中,用以下脚本提取:
$product_type = $xml->reference; echo $product_type;
这段代码会输出<reference>标签内的对应值。
同时获取节点名称和产品类型值
若需要一次性输出两者,可使用拼接脚本:
$node_name = $xml->getName(); $product_type_val = $xml->reference; echo "节点名称:{$node_name},产品类型:{$product_type_val}";
使用方法
在WP All Import的字段映射界面,选择「自定义代码/PHP函数」选项,将上述对应脚本粘贴到输入框中即可生效。
内容的提问来源于stack exchange,提问作者Fred
相关产品推荐
相关产品推荐

