这不是针对Magento开发的最具建设性问题。但这当然是让我感到困惑的人...

在靠背的洋红色订单网格上,我们看到订单占据了多行空间。 3而不是1 [从(商店)购买的列中]。这是因为我们有一个多功能。 RESUKT是我们在1个屏幕上看到正常订单数的1/3。没有大型,但我想改变一些东西。

我的问题:如何更改(商店)购买的列中的文本? 我希望它成为 商店查看名称 或者 商店域. 。也许在鼠标上显示了一个标题,确实显示了整个序列。下面的示例。

我正在寻找/app/code/core/mage/adminhtml/block/sales/order/grid.php,但不知道该如何从那里走并实际更改它。

@mage/eBay:我也认为这应该是为将来版本的配置中开/关的东西。

enter image description here

有帮助吗?

解决方案 2

我将store_view设置为false in file/app/code/core/mage/adminhtml/block/sales/sord/grid/grid.php

如果可以在后端通过配置设置此设置,那就太好了

    if (!Mage::app()->isSingleStoreMode()) {
        $this->addColumn('store_id', array(
            'header'    => Mage::helper('sales')->__('Purchased From (Store)'),
            'index'     => 'store_id',
            'type'      => 'store',
            'store_view'=> false,
            'display_deleted' => true,
        ));
    }

和edit/app/code/core/mage/adminhtml/block/widget/grid/column/renderer/store.php

功能渲染

/**        foreach ($data as $website) {
            $out .= $website['label'] . '<br/>';
            foreach ($website['children'] as $group) {
                $out .= str_repeat('&nbsp;', 3) . $group['label'] . '<br/>';
                foreach ($group['children'] as $store) {
                    $out .= str_repeat('&nbsp;', 6) . $store['label'] . '<br/>';
                }
            }
        }
**/

新队:

foreach ($data as $website) { $out .= $website['label'];}

并且在此更改了日期列的宽度$ this-> addcolumn('create_at'

  • 我们的dateFormat不是AM/PM,并将其设置为24小时,以config->目录中
  • 为什么此日期字符串比列宽度更长?

其他提示

你在正确的地方 开始 您的调查 app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php. 。看 _prepareColumns() 指示该列的渲染器:

protected function _prepareColumns()
{
    //snip...

    if (!Mage::app()->isSingleStoreMode()) {
        $this->addColumn('store_id', array(
            'header'    => Mage::helper('sales')->__('Purchased From (Store)'),
            'index'     => 'store_id',
            'type'      => 'store',
            'store_view'=> true,
            'display_deleted' => true,
        ));
    }

    //snip...
}

type 将导致此列由 Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Store::render() 方法:

public function render(Varien_Object $row)
{
    $out = '';
    $skipAllStoresLabel = $this->_getShowAllStoresLabelFlag();
    $skipEmptyStoresLabel = $this->_getShowEmptyStoresLabelFlag();
    $origStores = $row->getData($this->getColumn()->getIndex());

    if (is_null($origStores) && $row->getStoreName()) {
        $scopes = array();
        foreach (explode("\n", $row->getStoreName()) as $k => $label) {
            $scopes[] = str_repeat('&nbsp;', $k * 3) . $label;
        }
        $out .= implode('<br/>', $scopes) . $this->__(' [deleted]');
        return $out;
    }

    if (empty($origStores) && !$skipEmptyStoresLabel) {
        return '';
    }
    if (!is_array($origStores)) {
        $origStores = array($origStores);
    }

    if (empty($origStores)) {
        return '';
    }
    elseif (in_array(0, $origStores) && count($origStores) == 1 && !$skipAllStoresLabel) {
        return Mage::helper('adminhtml')->__('All Store Views');
    }

    $data = $this->_getStoreModel()->getStoresStructure(false, $origStores);

    foreach ($data as $website) {
        $out .= $website['label'] . '<br/>';
        foreach ($website['children'] as $group) {
            $out .= str_repeat('&nbsp;', 3) . $group['label'] . '<br/>';
            foreach ($group['children'] as $store) {
                $out .= str_repeat('&nbsp;', 6) . $store['label'] . '<br/>';
            }
        }
    }

    return $out;
}

多么可怕的方法!最多,块类应处理查看逻辑并准备在模板上下文中渲染的数据。在这里,我们看到了逻辑和标记的僵化。因此,您有两个选择来自定义:

  1. 用输出标记您喜欢的方式,重写此方法,或者
  2. 重写网格类以更改所使用的渲染器类型。

任何一种情况都可以证明是合理的。选项#1是最直接的,但是 它可能会影响使用相同渲染的其他观点. 。如果那是您想要的,那就去了。对于后者,您将声明一个自定义模块块类组,重写销售订单网格类,并指向您的自定义渲染器 type 范围。

您并不是一个人问eBay/Magento使它更加灵活。有一个黑客马拉松项目,使网格可在XML中配置,并且 Magento 2将此列为一个功能.

许可以下: CC-BY-SA归因
scroll top