我在优惠券代码的销售订单中添加了新列。添加此列排序工作正常,但当我过滤最后一天订单时,它显示出错了。 ajax问题在' mui / index / render'
应用\代码\ Vicomage \ CustomCoupon \等\ di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
应用\代码\ Vicomage \ CustomCoupon \等\ module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vicomage_CustomCoupon" setup_version="2.0.0">
</module>
</config>
应用\代码\ Vicomage \ CustomCoupon \模型\ ResourceModel \订单\网格\ Collection.php
<?php
namespace Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid;
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
class Collection extends OriginalCollection{
protected function _renderFiltersBefore()
{
$joinTable = $this->getTable('sales_order');
$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['coupon_code']);
parent::_renderFiltersBefore();
}
}
应用\代码\ Vicomage \ CustomCoupon \视图\ adminhtml \ ui_component \ sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="coupon_code">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Coupon Code</item>
</item>
</argument>
</column>
</columns>
</listing>
答案 0 :(得分:0)
在文件parent::_renderFiltersBefore()
的{{1}}之前添加以下代码行
app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php
让我知道您是否仍然面临同样的问题。