【问题标题】:Shopware 6: how to proof if product has variantsShopware 6:如何证明产品是否有变体
【发布时间】:2023-01-03 03:29:00
【问题描述】:

如果我打电话给产品,我会检查是否产品有变体.

目前,我使用 product.id 提出额外要求

...
const criteria = new Criteria();
criteria.setLimit(1);
criteria.addFilter(
    Criteria.equals('product.parentId', this.product.id)
);
this.productRepository
    .search(criteria)
    .then((result) => {
        ...
    });
...

我找不到合适的属性(字段),例如product.hasVariant

我认为这是一个简单的父子关系。我想知道实现此目标的唯一方法是否是在其子项中(具有 product.parentId 字段)。

题:

  • 是否有定义产品是否有变体的属性?
  • ……或者如果产品有变体,如何定义

【问题讨论】:

    标签: shopware6 shopware6-api


    【解决方案1】:

    是的,有一个名为childCount 的字段。

    记者:

    criteria.addFilter(Criteria.range('childCount', { gt: 0 }));
    

    应用程序接口:

    {
        "filter": [
            {
                "type": "range",
                "field": "childCount",
                "parameters": {
                    "gt": 0
                }
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 2021-01-01
      • 1970-01-01
      • 2023-01-20
      • 2022-11-10
      • 1970-01-01
      • 2020-11-21
      • 2022-09-26
      • 2023-01-20
      相关资源
      最近更新 更多