После добавления нового пользовательского столбца в фильтр magento 2 не работает сортировка по дате

Я добавил новый столбец в заказе на продажу для кода купона. после добавления этой сортировки столбцов работает нормально, но когда я фильтрую заказ за последний день, он показывает, что что-то пошло не так. проблема с ajax находится в 'mui/index/render'

приложение\код\Vicomage\CustomCoupon\etc\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\etc\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\Model\ResourceModel\Order\Grid\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\view\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>

person Suhel Rana    schedule 07.06.2018    source источник


Ответы (1)


добавьте следующие строки кода перед parent::_renderFiltersBefore() в файле app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php

$this->getSelect()->group('main_table.entity_id'); $this->getSelect()->group('main_table.store_id');

дайте мне знать, если вы все еще сталкиваетесь с той же проблемой.

person balwant singh    schedule 17.09.2018