基于规则的节点创建:商业产品+产品展示节点集

发布于 2024-11-17 14:36:08 字数 228 浏览 9 评论 0原文

我正在尝试将 Commerce 产品类型绑定到我自己的自定义类型节点(用作显示节点)。目标是在尽可能少的位置输入新数据。因此,我正在探索在创建另一种类型时基于规则创建一种类型。似乎两个方向都有效。不过,在这两者中,我更喜欢在用户创建自定义类型节点时自动创建商业产品,然后该节点将用作产品显示。

我想知道是否有人经历过这个选择并可以推荐这个。另外,commerce_product_display_manager 模块是否必要?

I'm trying to bind a Commerce product type to my own custom type node (serving as a display node). The goal is to enter new data in as few places as possible. I'm therefore exploring a rule-based creation of one type upon creation of the other. Seems like both directions are working. Of the two though, I prefer automatic creation of a Commerce Product upon user creation of Custom Type node, which will then serve as a product display.

I was wondering if anyone has been through this choice and could recommend this. Also, is the commerce_product_display_manager module necessary?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

茶底世界 2024-11-24 14:36:08

商业产品显示管理器不是必需的,我已经让它工作了,但我从未使用过该模块。

我选择了保存产品后自动创建节点的路线。

以下是我为此导出的规则:

{ "rules_create_product_display" : {
    "LABEL" : "Create Product Display",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : [ "commerce_product_insert" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-product:type" ], "value" : "**PRODUCT_TYPE**" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "**NODE_TYPE**",
            "param_title" : "[commerce-product:title]",
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:**PRODUCT_REFERENCE**" ],
          "value" : [ "commerce-product" ]
        }
      }
    ]
  }
}

您需要替换自己的值:

  • PRODUCT_TYPE(已创建的产品类型)
  • NODE_TYPE(正在创建的节点类型)
  • < strong>PRODUCT_REFERENCE(将引用所创建产品的字段)

抱歉,我现在无法投入更多时间来提供更好的答案,如果您希望我详细说明使用以下内容创建上述产品的过程,请告诉我图形用户界面

Commerce Product Display Manager is not necessary, I've gotten this to work and I've never used that module.

I went for the route of automatically creating a Node after saving the Product.

Below is my Rules export for this:

{ "rules_create_product_display" : {
    "LABEL" : "Create Product Display",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : [ "commerce_product_insert" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-product:type" ], "value" : "**PRODUCT_TYPE**" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "**NODE_TYPE**",
            "param_title" : "[commerce-product:title]",
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:**PRODUCT_REFERENCE**" ],
          "value" : [ "commerce-product" ]
        }
      }
    ]
  }
}

You'll need to substitute your own values for:

  • PRODUCT_TYPE (product type that has been created)
  • NODE_TYPE (node type being created)
  • PRODUCT_REFERENCE (field that will reference the created product)

Sorry I can't dedicate more time to a better answer now, let me know if you'd like me to elaborate on the process of creating the above using the GUI

你与清晨阳光 2024-11-24 14:36:08

上面的例子很有用,但这里是一个更具体的例子:

{ "rules_create_product_display_on_product_creation" : {
    "LABEL" : "Create Product Display on Product creation",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : [ "commerce_product_insert" ],
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "commerce-product" ], "type" : "commerce_product" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "product_display",
            "param_title" : "[commerce-product:title]",
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-product:0" ],
          "value" : [ "commerce-product" ]
        }
      }
    ]
  }
}

我遇到的唯一问题是第二个操作(“data_set”) - 选择“entity-created:field-product:0”,而不是“entity”很重要-created:field-product" 使其工作,因为我们想要分配特定产品而不是产品列表。

此示例使用标准产品显示节点类型 (product_display),但您可以将其更改为您正在使用的节点类型。另请记住,这仅适用于一种产品类型 - 对于每种产品类型,应创建单独的规则。您还可以创建一个规则,用于在删除产品时删除产品显示节点。
仅当您连接一产品一产品显示时,此规则才有用。如果您需要为每个产品显示添加更多产品(颜色、具有不同价格的图像),那么您必须使用 Commerce 批量产品创建 模块。

The above example was useful but here is a more specific one:

{ "rules_create_product_display_on_product_creation" : {
    "LABEL" : "Create Product Display on Product creation",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : [ "commerce_product_insert" ],
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "commerce-product" ], "type" : "commerce_product" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "product_display",
            "param_title" : "[commerce-product:title]",
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-product:0" ],
          "value" : [ "commerce-product" ]
        }
      }
    ]
  }
}

The only problem I had was with the second action ("data_set")- it was important to select "entity-created:field-product:0", not the "entity-created:field-product" to make it work because we want to assign specific product and not a list of products.

This example is using the standard product display node type (product_display) but you can change it with the one you are using. Also have in mind that this is working only for one product type - for every product type a separated rule should be created. You may create also a rule for deleting the product display node when deleting the product.
This rule is useful only when you have connection one product-one product display. If you need to add more products per product display (colors, images with different prices) then you have to use Commerce Bulk Product Creation module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文