小编Gab*_*iel的帖子

Shopware 6 - 用于管理中实体扩展的表单字段

这是 Shopware 6 的问题。我想PromotionEntity通过添加一个max_budget字段并将其显示为管理中的表单字段来扩展。目前仅存在max_redemptions_global和字段。max_redemptions_per_customer该字段应出现在和字段max_budget下方的管理中。其行为与其他两个类似。如果此促销活动的总订单折扣达到 max_budget 中的值,则促销活动不再有效。max_redemptions_globalmax_redemptions_per_customermax_budget

所以我创建了一个实体扩展,如下所示:

class PromotionMaxBudgetExtension extends EntityExtension
{
    public function extendFields(FieldCollection $collection): void
    {
        $collection->add(
            new OneToOneAssociationField('maxBudget', 'id', 'promotion_id', PromotionMaxBudgetDefinition::class, false)
        );
    }

    public function getDefinitionClass(): string
    {
        return PromotionDefinition::class;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后是扩展的定义:

class PromotionMaxBudgetDefinition extends EntityDefinition
{
    public const ENTITY_NAME = 'promotion_max_budget';

    public function getEntityName(): string
    {
        return self::ENTITY_NAME;
    }

    public function getEntityClass(): string
    {
        return PromotionMaxBudgetEntity::class;
    }

    protected function defineFields(): FieldCollection …
Run Code Online (Sandbox Code Playgroud)

shopware shopware6

3
推荐指数
1
解决办法
1506
查看次数

标签 统计

shopware ×1

shopware6 ×1