如何自定义 Sylius 以销售免费产品(默认最低价格为 0.01)

how to customize Sylius in order to sell free products (by default the min. price is 0.01)

我必须基于 sylius 建立一个能够销售免费产品的商店。 为此,我遵循了文档“Customizing Validation”并进行了修改:

#AppBundle/Resources/config/validation.yml
Sylius\Component\Core\Model\ChannelPricing:
    # see http://docs.sylius.org/en/latest/customization/validation.html
    #the original constraint said that the minimum price is 0.01 in vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Resources/config/validation/ChannelPricing.xml
    properties:
        price:
            - NotBlank:
                message: sylius.channel_pricing.price.not_blank
                groups: [app_product]
            - Range:
                min: 0
                minMessage: app.channel_pricing.price.min
                groups: [app_product]

#app/config/parameters.yml
parameters:
    sylius.form.type.channel_pricing.validation_groups: [app_product] # see http://docs.sylius.org/en/latest/customization/validation.html

它没有任何结果:在 symfony 分析器中,sylius 验证组仍然适用。

我想不通我做错了什么。

请注意:

我复制粘贴@pjedrzejewski 的回答:

Perhaps you should use a promotion to apply proper discount and get the order total to 0? Then Sylius should handle it just fine. I am not sure we should allow setting price 0, it can lead to terrible mistakes