Magento2将订单状态添加到管理订单列表中的属性类

时间:2016-11-23 22:23:22

标签: magento2

我希望在管理订单列表中获取不同颜色的订单(表格行),具体取决于其状态。我认为最简单的是在渲染订单表和相应的CSS代码时添加一个类的状态,但我不知道该怎么做。

我有:

<tr class="data-row" data-bind="css: {'_odd-row': $index % 2}" data-repeat-index="0">

需要:

<tr class="data-row pending" data-bind="css: {'_odd-row': $index % 2}" data-repeat-index="0">

抱歉我的英文。

1 个答案:

答案 0 :(得分:0)

找到答案。修改vendor / magento / module-ui / view / base / web / templates / grid / listing.html

    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class FrontofficeControllerExceptionFilterAttribute : ExceptionFilterAttribute
{
    protected readonly ILogger<FrontofficeController> _logger;
    protected readonly IHostingEnvironment _hostingEnvironment;
    protected readonly IModelMetadataProvider _modelMetadataProvider;

    public FrontofficeControllerExceptionFilterAttribute(ILogger<FrontofficeController> logger, IHostingEnvironment hostingEnvironment, IModelMetadataProvider modelMetadataProvider)
    {
        _logger = logger;
        _hostingEnvironment = hostingEnvironment;
        _modelMetadataProvider = modelMetadataProvider;
    }

    public override void OnException(ExceptionContext context)
    {
        if (context.ExceptionHandled) return;

        Exception ex = context.Exception;
        var result = new ViewResult { ViewName = "ApplicationError" };

        context.ExceptionHandled = true; // mark exception as handled
        context.Result = result;
    }
}

我还在等待更好的解决方案