在管理中更改订单网格行颜色的方法

发布于 2024-11-18 06:02:46 字数 91 浏览 2 评论 0原文

我需要根据订单状态更改 magento 订单网格中的行颜色。 首先,我不需要具有可配置界面的复杂解决方案。 我只是想知道从哪里开始。

最好的方法是什么?

I need to change row color in magento orders grid based on order status.
For start I don't want a complex solution with configurable interface.
I just want to know where to start.

What is the best approach ?

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

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

发布评论

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

评论(1

作妖 2024-11-25 06:02:46

完整、可行的解决方案:

js/mage/adminhtml/grid.js复制到js/colors/adminhtml/grid.js

制作文件666和文件夹 (js/colors & js/colors/adminhtml) 777。

编辑它并在第 208 行之后(在包含 }.bind(this) 的行之前)添加:

colorize();

在文件末尾添加:

function colorize () {
    $('td').each(function(macguffin) {
       if(macguffin.innerHTML.strip()=="Processing") macguffin.parentNode.setStyle({backgroundColor: 'Orange' });
        if(macguffin.innerHTML.strip()=="Pending") macguffin.parentNode.setStyle({backgroundColor: 'Gold', color:'Black' });
        if(macguffin.innerHTML.strip()=="Payment Review") macguffin.parentNode.setStyle({backgroundColor: 'LightPink' });
        if((macguffin.innerHTML.strip()=="On Hold")||(macguffin.innerHTML.strip()=="Payment Review")) macguffin.parentNode.setStyle({backgroundColor: 'HotPink' });
        if(macguffin.innerHTML.strip()=="Suspected Fraud") macguffin.parentNode.setStyle({backgroundColor: 'Red' });
        if((macguffin.innerHTML.strip()=="Closed")||(macguffin.innerHTML.strip()=="Canceled")||(macguffin.innerHTML.strip()=="Cancelled")) macguffin.parentNode.setStyle({backgroundColor: 'LightBlue', fontStyle: 'italic' });
        if(macguffin.innerHTML.strip()=="Complete") macguffin.parentNode.setStyle({backgroundColor: 'Green' });
  });
}
document.observe("dom:loaded", colorize);

现在在 app/design/adminhtml/default/default/layout/local.xml 中创建或编辑 admin local.xml 文件

编辑它以包括:

<?xml version="1.0"?>
<layout version="0.1.0">
  <default>
    <reference name="head">
        <action method="removeItem"><type>js</type><name>mage/adminhtml/grid.js</name></action>
        <action method="addItem"><type>js</type><name>colors/adminhtml/grid.js</name></action> 
    </reference>
  </default>
</layout>

订单网格现在将颜色鲜艳,您应该能够清楚地看到哪些订单需要注意。

可以编辑 colorize() 函数以适合您的订单状态和首选配色方案。

Full, working solution:

Copy js/mage/adminhtml/grid.js to js/colors/adminhtml/grid.js

Make the file 666 and the folders (js/colors & js/colors/adminhtml) 777.

Edit it and after line 208 (before the line containing }.bind(this)) add:

colorize();

At the end of the file add:

function colorize () {
    $('td').each(function(macguffin) {
       if(macguffin.innerHTML.strip()=="Processing") macguffin.parentNode.setStyle({backgroundColor: 'Orange' });
        if(macguffin.innerHTML.strip()=="Pending") macguffin.parentNode.setStyle({backgroundColor: 'Gold', color:'Black' });
        if(macguffin.innerHTML.strip()=="Payment Review") macguffin.parentNode.setStyle({backgroundColor: 'LightPink' });
        if((macguffin.innerHTML.strip()=="On Hold")||(macguffin.innerHTML.strip()=="Payment Review")) macguffin.parentNode.setStyle({backgroundColor: 'HotPink' });
        if(macguffin.innerHTML.strip()=="Suspected Fraud") macguffin.parentNode.setStyle({backgroundColor: 'Red' });
        if((macguffin.innerHTML.strip()=="Closed")||(macguffin.innerHTML.strip()=="Canceled")||(macguffin.innerHTML.strip()=="Cancelled")) macguffin.parentNode.setStyle({backgroundColor: 'LightBlue', fontStyle: 'italic' });
        if(macguffin.innerHTML.strip()=="Complete") macguffin.parentNode.setStyle({backgroundColor: 'Green' });
  });
}
document.observe("dom:loaded", colorize);

Now create or edit the admin local.xml file in app/design/adminhtml/default/default/layout/local.xml

Edit it to include:

<?xml version="1.0"?>
<layout version="0.1.0">
  <default>
    <reference name="head">
        <action method="removeItem"><type>js</type><name>mage/adminhtml/grid.js</name></action>
        <action method="addItem"><type>js</type><name>colors/adminhtml/grid.js</name></action> 
    </reference>
  </default>
</layout>

The orders grid will now be in vibrant colours and you should be able to clearly see what orders need attention.

The colorize() function can be edited to suit your order states and preferred colour scheme.

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