Skip to main content
added 799 characters in body
Source Link
Prits
  • 623
  • 8
  • 50

I have save my custom data in quote and sales_order table and show data in Admin grid but filter is not working in this as it is search in sales_order_grid table in Magento 2.

I have found out a solution using virtualType in di.xml but still it doesn't work.

my di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Reg\Checkout\Api\Data\CustomFieldsInterface" type="Reg\Checkout\Model\Data\CustomFields" />
<preference for="Reg\Checkout\Api\CustomFieldsRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsRepository" />
<preference for="Reg\Checkout\Api\CustomFieldsGuestRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsGuestRepository" />
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
    <arguments>
        <argument name="columns">
            <item name="custom_value" xsi:type="string">sales_order.custom_value</item>
        </argument>
    </arguments>
</virtualType>
</config>

Still it doesn't work can anyone point out what's the issue.

Any help is appreciated.

Error

Column not found: 1054 Unknown column 'custom_value' in 'where clause', query was: SELECT COUNT(*) FROM `sales_order_grid` AS `main_table` WHERE (`custom_value` = 'facebook') AND (`custom_value` LIKE '%facebook%') {"exception":"[object] (Zend_Db_Statement_Exception(code: 42): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_value' in 'where clause', query was: SELECT COUNT(*) FROM `sales_order_grid` AS `main_table` WHERE (`custom_value` = 'facebook') AND (`custom_value` LIKE '%facebook%') at /var/www/html/mag/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_value' in 'where clause' at /var/www/html/mag/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []

I have save my custom data in quote and sales_order table and show data in Admin grid but filter is not working in this as it is search in sales_order_grid table in Magento 2.

I have found out a solution using virtualType in di.xml but still it doesn't work.

my di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Reg\Checkout\Api\Data\CustomFieldsInterface" type="Reg\Checkout\Model\Data\CustomFields" />
<preference for="Reg\Checkout\Api\CustomFieldsRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsRepository" />
<preference for="Reg\Checkout\Api\CustomFieldsGuestRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsGuestRepository" />
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
    <arguments>
        <argument name="columns">
            <item name="custom_value" xsi:type="string">sales_order.custom_value</item>
        </argument>
    </arguments>
</virtualType>
</config>

Still it doesn't work can anyone point out what's the issue.

Any help is appreciated.

I have save my custom data in quote and sales_order table and show data in Admin grid but filter is not working in this as it is search in sales_order_grid table in Magento 2.

I have found out a solution using virtualType in di.xml but still it doesn't work.

my di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Reg\Checkout\Api\Data\CustomFieldsInterface" type="Reg\Checkout\Model\Data\CustomFields" />
<preference for="Reg\Checkout\Api\CustomFieldsRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsRepository" />
<preference for="Reg\Checkout\Api\CustomFieldsGuestRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsGuestRepository" />
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
    <arguments>
        <argument name="columns">
            <item name="custom_value" xsi:type="string">sales_order.custom_value</item>
        </argument>
    </arguments>
</virtualType>
</config>

Still it doesn't work can anyone point out what's the issue.

Any help is appreciated.

Error

Column not found: 1054 Unknown column 'custom_value' in 'where clause', query was: SELECT COUNT(*) FROM `sales_order_grid` AS `main_table` WHERE (`custom_value` = 'facebook') AND (`custom_value` LIKE '%facebook%') {"exception":"[object] (Zend_Db_Statement_Exception(code: 42): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_value' in 'where clause', query was: SELECT COUNT(*) FROM `sales_order_grid` AS `main_table` WHERE (`custom_value` = 'facebook') AND (`custom_value` LIKE '%facebook%') at /var/www/html/mag/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_value' in 'where clause' at /var/www/html/mag/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []
Source Link
Prits
  • 623
  • 8
  • 50

Filter is not working on Custom Values in Magento 2 Order?

I have save my custom data in quote and sales_order table and show data in Admin grid but filter is not working in this as it is search in sales_order_grid table in Magento 2.

I have found out a solution using virtualType in di.xml but still it doesn't work.

my di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Reg\Checkout\Api\Data\CustomFieldsInterface" type="Reg\Checkout\Model\Data\CustomFields" />
<preference for="Reg\Checkout\Api\CustomFieldsRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsRepository" />
<preference for="Reg\Checkout\Api\CustomFieldsGuestRepositoryInterface" type="Reg\Checkout\Model\CustomFieldsGuestRepository" />
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
    <arguments>
        <argument name="columns">
            <item name="custom_value" xsi:type="string">sales_order.custom_value</item>
        </argument>
    </arguments>
</virtualType>
</config>

Still it doesn't work can anyone point out what's the issue.

Any help is appreciated.